[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02610] Re: Requiring more flexible require

From: matz@... (Yukihiro Matsumoto)
Date: 2000-05-01 08:49:23 UTC
List: ruby-talk #2610
Hi,

In message "[ruby-talk:02604] Requiring more flexible require"
    on 00/04/28, mrilu <mrilu@ale.cx> writes:

|I thought to ask and provide an opportunity for someone to give me 
|a glimpse of deep reasoning behind 'require'. Why it figures out the 
|name of the initialization routine from given filename and why it 
|looks strictly for the library file named as the given filename?
|
|Consider the following test case. I have foo.c and shared library libfoo.so . 
|Then I have bar.c and it's using routine foo defined at foo.c, and there's
|another shared libbar.so .
|
|Then I want to use these from Ruby so I make wrappers (with SWIG) for 
|both libraries, and make new shared libs libfoo_wrap.so and libbar_wrap.so. 
|I really like to have them named _wrap because I have already programs
|which are using the libxxx.so versions. And I really like to have them 
|prefixed 'lib' because on the C side the 'ld -lname' looks for libname.so. 
|(I know I could cope with symlinks, but it feels clumsy for this one.)
|
|So we have ('->' means processed: compiled, generated shared library):
|foo.c     -> foo.o                  -> libfoo.so
|bar.c     -> bar.o  with libfoo.so  -> libbar.so
|progfoo.c -> with libfoo.so         -> progfoo
|progbar.c -> with libbar.so         -> progbar
|
|foo.c   -> foo_wrap.c -> foo_wrap.o -> libfoo_wrap.so
|bar.c   -> bar_wrap.c -> bar_wrap.o with libfoo_wrap.so -> libbar_wrap.so
|
|Now, few problems are raised:
|1) require 'foo'
|Does not work. There's no foo.so. Closest is libfoo.so but it's the 
|C version, not the wrapped one.
|
|2) require 'foo_wrap' 
|Does not work. There's no foo_wrap.so file. Should be libfoo_wrap.so.
|
|3) require 'libfoo_wrap'
|Does not work. There's no Init_libfoo_wrap routine in libfoo_wrap.so.
|There is, however, Init_Foo().
|
|4) require 'Foo'
|Does not work. Would call right initialization routine but unfortunately
|there's no Foo.so. So this needs link Foo.so -> libfoo_wrap.so. This in
|turn is a little bit confusing when we have foo.so around too.
|
|So my propose would be to change syntax and semantics for require.

First of all, you have to distinguish OS's shared libraries and Ruby's
dynamically loadable extension.  They have both file extension (.so)
and in same binary format, but similarity ends there.

You have shared library libfoo.so and libbar.so, and wrapper routines
in foo.c and foo.bar.  So why don't you choose foo.so and bar.so for
extension name?  Ruby does not use `ld' inside.  You don't need to
prefix extension names by `lib'.

Do I miss something?

							matz.

In This Thread

Prev Next