EuLisp programs are comprised of a number of modules. This means that if you want to write a program as a character file and load that into EuLisp, you must define a module. Exactly how to do this will be covered shortly.

Euscheme displays the current module as part of its prompt, eg.

user> which means that the focus is currently the module called user. You can change the focus to another module using the operator !>, for example (!> xyz). If that module is loaded, then the focus is changed to module xyz. If the xyz module is currently not loaded then euscheme tries to open a file called xyz.em in the directories in the path stored in the shell variable EU_MODULE_PATH. If this is null, then euscheme only searches the directory in which euscheme was started. For example: user> (!> xyz) xyz> (!> abc) Error---calling default handler: Condition class is # message: "unknown module in enter-module" value: abc Debug loop. Type help: for help Broken at # DEBUG> top: Shows the system changing the focus from module user to module xyz (already loaded) and from there to module abc. Unfortunately, module abc is not loaded, and EuScheme cannot find a file called abc.em in order to load it.

Module definition

If module A needs to use some functions defined in module B, then module A must import module B, and module B must also export the necessary functions. Probably the most common case is wanting to use the functionality of the EuLisp language, in which case your module must import the module level-0, for example: (defmodule abc (import (level-0)) (defun f (x) (if (> x 2) 1 (* x (f (- x 1))))) (export f) ) This defines a module abc which imports the level-0 EuLisp language, defines a function f and exports the binding f. It is a requirement that the first part of the name of the file and the name of the module be identical, eg. abc.em must be the name of the file containing the above module definition.

Thus the syntax for defining a module looks like this:

(defmodule module-name import-list defn-1 ... defn-n)

Where the items in italics have the following properties:

The name of the module has the same syntax as that of an identifier, but is slightly restricted in that it must also be acceptable as part of the name of the file as described above.
An expression of the form (import (module-1 ... module-n)). When this module is loaded, the imported modules will be loaded first, and in the order given, if not already loaded.
defn-1 ... defn-n
Where each defn-i is either a definition (defun, deflocal, defgeneric, defmethod, defclass), or an export expression of the form (export id-1 ... id-n), where id-i is an identifier defined in this module or in an imported module.
There are other features of the EuLisp module system which are not covered here, but the above should be adequate for most purposes.
Julian Padget,, this version February 1, 1995