- load filename #!optional evalprocprocedure
Filename should be a string naming an existing file containing Scheme source code. The load procedure reads expressions and definitions from the file and evaluates them sequentially. It is unspecified whether the results of the expressions are printed. The load procedure does not affect the values returned by current-input-port and current-output-port. Load returns an unspecified value.
CHICKEN offers a few extensions to the R5RS definition of load:
- The filename may also be an input port.
- The expressions which are read one by one from the source file are passed to the procedure indicated by the extra optional evalproc argument, which defaults to eval.
- On platforms that support it (currently BSD, Haiku, MacOS X, Linux, Solaris, and Windows), load can be used to load shared objects.
Example for loading compiled programs:
% cat x.scm (define (hello) (print "Hello!")) % csc -s x.scm % csi -q #;1> (load "x.so") ; loading x.so ... #;2> (hello) Hello! #;3>
There are some limitations and caveats to the CHICKEN extensions you need to be aware of:
- The second argument to load is ignored when loading compiled code.
- If source code is loaded from a port, then that port is closed after all expressions have been read.
- A compiled file can only be loaded once. Subsequent attempts to load the same file have no effect.