[gambit-list] Gambit linking

Marc Feeley feeley at iro.umontreal.ca
Wed Nov 6 10:45:58 EST 2013


On Nov 6, 2013, at 3:03 AM, Álvaro Castro-Castilla <alvaro.castro.castilla at gmail.com> wrote:

> It would be like a module system without the namespaces.

Yes, that's a way to put it.

Note that my proposal only aims to provide a very basic mechanism for loading in a VM modules of code with their dependencies. The "depends-on" form could of course be used for building a (slightly) higher-level module system to ensuring that module dependencies are satisfied.  By the way, I think this form is probably best called preload-module, so that a program could be written like this:

(define (f n)
  (preload-module math)
  (+ (math:cbrt n) (math:fact n)))

(define (g x)
  (preload-module postscript)
  (preload-module math)
  (postscript:circle (math:square x)))

The code would be roughly equivalent to:

(if (not (loaded? 'math)) (load 'math))
(if (not (loaded? 'postscript)) (load 'postscript))

(define (f n)
  (+ (math:cbrt n) (math:fact n)))

(define (g x)
  (postscript:circle (math:square x)))

In other words, the requests to preload modules are just annotations that are accumulated for the whole module.  The set of requests causes these modules to be loaded at the very beginning of the module's execution.

> I think that this is a very nice step, because it's an important part of the functionality of Blackhole or Schemespheres, but with the new features that you can implement at a lower level.
> I'd actually like that this goes one step further an build a minimal module system (even if just select which variables to export per module). Such a simple module system (export / depends-on) would be very helpful for developing bigger applications with Gambit.

I agree that a lightweight module system would be nice.  This should be fairly simple to do once the linker is modified to support preload-module.

Marc




More information about the Gambit-list mailing list