Subject: Re: support runtime picking of module
From: (Rob Warnock)
Date: 2000/06/29
Newsgroups: comp.lang.scheme
Message-ID: <8jfbpa$41s68$>
Vardhan Varma  <> wrote:
| I'm looking for a scheme implementation which can pick
| a module ( written in C , and made a .so ) on the fly.

All of SCM, MzScheme, and Elk can do this (and certainly others as well).

Under MzScheme, the call is (load-extension "/path/to/").
This links to the .so and calls the "scheme_initialize()" procedure
in it, which may in turn defined new primitive Scheme procedures
[with "scheme_make_prim()" or "scheme_make_prim_w_arity()"] and
install them in global Scheme variables [with "scheme_add_global()"].

Under Elk it's similar, but you say (require '  [or even just
(require 'foo.o), and it'll run the linker at runtime], and the routine
that's called in the module is any symbol named "elk_init_XXX" (for any XXX).

SCM [the last time I looked] provides a Scheme procedure "dyn:link" to
do a "dlopen()" on a .so, and a "dyn:call" to call a procedure in it
(usually an init procedure like the above, since you can't pass any args
through a "dyn:call").


Rob Warnock, 41L-955
Applied Networking
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043