Dump, (also known as unexec), saves the continuation of an entire SCM session to an executable file, which can then be invoked as a program. Dumped executables start very quickly, since no Scheme code has to be loaded.
There are constraints on which sessions are savable using
current-error-port), X windows, etc. are invalid in subsequent invocations.
This restriction could be removed; See Improvements To Make.
Dumpshould only be called from a loading file when the call to dump is the last expression in that file.
Dumpcan be called from the command line.
- Creates an executable program named newpath which continues the state of the current SCM session when invoked. The optional argument thunk, if provided, should be a procedure of no arguments; boot-tail will be set to this procedure, causing it to be called in the restored executable.
If the optional argument is missing or a boolean, SCM's standard command line processing will be called in the restored executable.
If the second argument to
#t, argument processing will continue from the command line passed to the dumping session. If the second argument is missing or
#fthen the command line arguments of the restoring invocation will be processed.
- Resumes the top level Read-Eval-Print loop. This is done instead of continuing normally to avoid creating a saved continuation in the dumped executable.
dumpmay set the values of
restart, and *interactive*.
dumpreturns an unspecified value.
When a dumped executable is invoked, the variable *interactive*
(see Internal State) has the value it possessed when
created it. Calling
dump with a single argument sets
#f, which is the state it has at the
beginning of command line processing.
program-arguments returns the command line
arguments for the curent invocation. More specifically,
program-arguments for the restored session are not saved
from the dumping session. Command line processing is done on
the value of the identifier
The following example shows how to create ‘rscm’, which is like regular scm, but which loads faster and has the ‘random’ package alreadly provided.
bash$ scm -rrandom > (dump "rscm") #<unspecified> > (quit) bash$ ./rscm -lpi.scm -e"(pi (random 200) 5)" 00003 14159 26535 89793 23846 26433 83279 50288 41971 69399 37510 58209 74944 59230 78164 06286 20899 86280 34825 34211 70679 82148 08651 32823 06647 09384 46095 50582 23172 53594 08128 48111 74502 84102 70193 85211 05559 64462 29489 bash$
This task can also be accomplished using the ‘-o’ command line option (see SCM Options).
bash$ scm -rrandom -o rscm > (quit) bash$ ./rscm -lpi.scm -e"(pi (random 200) 5)" 00003 14159 26535 89793 23846 26433 83279 50288 41971 69399 37510 58209 74944 59230 78164 06286 20899 86280 34825 34211 70679 82148 08651 32823 06647 09384 46095 50582 23172 53594 08128 48111 74502 84102 70193 85211 05559 64462 29489 bash$