[plt-scheme] doing without load-extension

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Nov 15 17:37:38 EST 2007

At Thu, 15 Nov 2007 22:12:46 +0000, Dave Griffiths wrote:
> Is it possible to write modules which use extensions but don't need to
> have load-extension called before they are require'd?
> 
> For example, I'm currently having to do something like this:
> 
> (load-extension "path/to/my-extension.so")
> 
> (module my-module mzscheme
>    (require my-extension-namespace)
>    ...
> )

The key is to put the extension in a place where it is found as an
alternative to Scheme source.

For example, you could put it in

  (build-path "compiled" (system-library-subpath) "my-extension.so")

relative to "my-module.ss", and then change "my-module.ss" to

 (module my-module mzscheme
   (require "my-extension.ss")
   ...)

then when the module loader looks for "my-extension.ss", it will pick
up "my-extension.so", instead.

If you're using v3.99 instead of v371.3 or earlier, then name the file
"my-extension_ss.so" (i.e, with an extra "_ss").

Matthew



Posted on the users mailing list.