-----

Scheme48 Modules

-----

Scheme48 includes a module system, which allows the user to divide code into groups. The group structure allows code to be loaded selectively and also prevents unwanted access to internal variables and procedures. This page contains basic directions on how to use the module system.

Loading library code

A number of useful utilities are either built in to Scheme 48 or can be loaded from an external library. These utilities are not visible in the user environment by default, but can be made available with the ,open command. For example, to use the tables structure, do

    > ,open tables
    > 

If the utility is not already loaded, then the ,open command will offer to load it:

    > ,open queues
    Load structure queues (y/n)? 

Or, you can load something explicitly (without opening it) using the load-package command:

    > ,load-package queues
    ...
    > ,open queues

When loading a utility, the message "Note: optional optimizer not invoked" is innocuous. Feel free to ignore it.

Defining a module

Here is a simple example of a module definition:

(define-structure blc (export (set-values! :syntax)
                            blc-register-function)
  (open scheme-level-2  
        signals        ; to get error
        formats)       ; to get format
  (files multiple-values
         symbol-tables 
         scheme-functions))

This module exports two symbols:

Mysterious and uninformative errors happen if you don't open scheme (either level-0, level-1, or level-2) explicitly in the module definition.

The filenames are in the same directory as blc-package.scm. To specify a file foo in a subdirectory mumble relative to this mother directory, do

Absolute pathnames are also possible

Loading a user-defined module

To load this module, do

Symbols exported by this module will become accessible in the user package.

Writing code in a module

If you are working on code that will eventually live in this module, it probably won't run in the user package because it must access non-exported symbols. Or, more likely, scheme48 being what it is, it will pretend to run but generate mysterious errors. You need to switch into the new package:

You have to load the package first, but you don't have to open it before moving to it.

If you need to switch back to the user package (e.g. to check exports), do

If you haven't already done so, you have to open your new package once you are in the user package.

To reload a package after changing the code and/or the package specification, do

-----

Ownership, Maintenance and Disclaimers

Envision Manual Top Page

Last modified