[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MzScheme library question



Hi Matthew,
Once more I am impressed by PLT support.
Looks great.Cant hardly wait for the next release.
Thanks a lot. Jos
Jacob J. A. Koot

Matthew Flatt wrote:
Quoting "Jacob J. A. Koot":
> Is it correct to post questions about MzScheme in this list?

Yes.

> I
> would be much obliged if you can point me to a reasonably simple way to
> construct a tool for preparing and loading/requiring libraries meeting the
> following criteria:
> 1: the values returned by the library do not depend on the environment in
> which the library is loaded/required, i.e. no need for hash-percent,
except
> may be in the expansion of macros.
> 2: an option to prevent the library from overriding the value or syntactic
> binding of any variable that at load/require time happens already to be
> bound in the global namespace of the calling program. Say
> (require-library-dont-override name collects ...)
> 3: an option for the specification of symbols that may be redefined
despite
> of requirement 2, say (require-library-dont-override-except (symbol ...)
> name collects ...)
> 4: load/require commands within a library preferably do not load a copy if
> already loaded. May be loading can even be lazy.
> 5: if the library loads/requires other libraries, it must still meet the
> above conditions

Hey -- good timing! The module system in MzScheme version 200 will do
exactly these things.

In 200, instead of

 (require-library "lib.ss" "collection")

you'll import library-based module bindings with

 (require (lib "lib.ss" "collection"))

either into the top level, or into a module context.


If you want everything from the library except it's a, b, and c:

 (require (all-except (lib "lib.ss" "collection") a b c))

If you want *only* the library's z, you have to drop down to the most
general form:

 (require (rename (lib "lib.ss" "collection") z z))


The library "lib.ss" is defined via the new `module' form, which means
that its language is fixed. Other library modules that "lib.ss" depends
on (and that haven't been loaded already) are automatically loaded when
the module is loaded. No #%, not even for macros.


More news later today on how you can get the bleeding-edge
implementation...

Matthew