Next: , Previous: , Up: Using Scheme   [Contents][Index]


3.2 Loading Files

To load files of Scheme code, use the procedure load:

procedure: load filename [environment [syntax-table [purify?]]]

Filename may be a string naming a file, or a list of strings naming multiple files. Environment, if given, is the environment to evaluate the file in; if not given the current REPL environment is used.

Syntax-table is no longer used and if supplied will be ignored.

The optional argument purify? is a boolean that says whether to move the contents of the file into constant space after it is loaded but before it is evaluated. This is performed by calling the procedure purify (see Garbage Collection). If purify? is given and true, this is done; otherwise it is not.

load determines whether the file to be loaded is binary or source code, and performs the appropriate action. By convention, files of source code have names ending in .scm, and files of binary SCode have names ending in .bin. Native-code binaries have names ending in .com. R7RS library files conventionally end in .sld, .binld, and .comld respectively.

If no file-name suffix is specified, load will choose a file by trying different suffixes, preferring in order native-code binaries, SCode binaries, and source files.

All file names are interpreted relative to a working directory, which is initialized when Scheme is started. The working directory can be obtained by calling the procedure pwd or modified by calling the procedure cd; see Working Directory in MIT/GNU Scheme Reference Manual.

procedure: load-option symbol [no-error?]

Loads the option specified by symbol; if already loaded, does nothing. Returns symbol; if there is no such option, an error is signalled. However, if no-error? is specified and true, no error is signalled in this case, and #f is returned.

A number of built-in options are defined:

compress

Support to compress and uncompress files. Undocumented; see the source file runtime/cpress.scm. Used by the runtime system for compression of compiled-code debugging information.

format

The format procedure. See Format in MIT/GNU Scheme Reference Manual.

gdbm

Support to access gdbm databases. Undocumented; see the source files runtime/gdbm.scm and microcode/prgdbm.c.

ordered-vector

Support to search and do completion on vectors of ordered elements. Undocumented; see the source file runtime/ordvec.scm.

regular-expression

Support to search and match strings for regular expressions. See Regular Expressions in MIT/GNU Scheme Reference Manual.

stepper

Support to step through the evaluation of Scheme expressions. Undocumented; see the source file runtime/ystep.scm. Used by the Edwin command step-expression.

subprocess

Support to run other programs as subprocesses of the Scheme process. Undocumented; see the source file runtime/process.scm. Used extensively by Edwin.

synchronous-subprocess

Support to run synchronous subprocesses. See Subprocesses in MIT/GNU Scheme Reference Manual.

In addition to the built-in options, you may define other options to be loaded by load-options by modifying the file optiondb.scm on the library path. An example file is included with the distribution; normally this file consists of a series of calls to the procedure define-load-option, terminated by the expression

(further-load-options standard-load-options)
procedure: define-load-option symbol thunk …

Each thunk must be a procedure of no arguments. Defines the load option named symbol. When the procedure load-option is called with symbol as an argument, the thunk arguments are executed in order from left to right.


Next: World Images, Previous: The Read-Eval-Print Loop, Up: Using Scheme   [Contents][Index]