Next: , Previous: , Up: Packages   [Contents][Index]

5.2 Dump

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 dump

Function: dump newpath
Function: dump newpath #f
Function: dump newpath #t
Function: dump newpath thunk
  • Calls gc.
  • 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 dump is #t, argument processing will continue from the command line passed to the dumping session. If the second argument is missing or #f then 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.

dump may set the values of boot-tail, *argv*, restart, and *interactive*. dump returns an unspecified value.

When a dumped executable is invoked, the variable *interactive* (see Internal State) has the value it possessed when dump created it. Calling dump with a single argument sets *interactive* to #f, which is the state it has at the beginning of command line processing.

The procedure 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 *argv*.

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 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$ 

Next: , Previous: , Up: Packages   [Contents][Index]