Next: , Previous: Dynamic Linking, Up: Packages


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

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