Go to the first, previous, next, last section, table of contents.

Loading Files

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

procedure: load filename [environment [syntax-table]]
Filename may be a string naming a file, or a list of strings naming many files. Environment, if given, is the environment to evaluate the file in; if not given the current REPL environment is used. Likewise syntax-table is the syntax table to use.

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 a pathname type of "scm", and files of binary SCode have pathname type "bin". Native-code binaries have pathname type "com". (See the description of pathname-type in the reference manual.)

variable+: load-noisily?
If load-noisily? is set to #t, load will print the value of each expression in the file as it is evaluated. Otherwise, nothing is printed except for the value of the last expression in the file. (Note: the noisy loading feature is implemented for source-code files only.)

variable+: load/default-types
When load is given a pathname without a type, it uses the value of this variable to determine what pathname types to look for and how to load the file. load/default-types is a list of associations that maps pathname types (strings) to loader procedures. load tries the pathname types in the order that they appear in the list. The initial value of this variable has pathname types in this order:

"com" "so" "sl" "bin" "scm"

This means that, for example, (load "foo") will try to load `foo.com' first, and `foo.scm' only after looking for and failing to find the other pathname types.

All pathnames are interpreted relative to a working directory, which is initialized when Scheme is started. The working directory can be obtained from the procedure pwd or modified by the procedure cd; see the reference manual for details. Files may be loaded when Scheme first starts; see the -load command line option for details.

Go to the first, previous, next, last section, table of contents.