run.texi 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. @node Running Scheme48
  2. @section Running Scheme48
  3. @cindex heap image resumption
  4. @cindex resuming heap images
  5. Scheme48 is run by invoking its virtual machine on a dumped heap image
  6. to resume a saved system state. The common case of invoking the
  7. default image, @file{scheme48.image}, which contains the usual command
  8. processor, run-time system, @etc{}, is what the @command{scheme48}
  9. script that is installed does. The actual virtual machine executable
  10. itself, @command{scheme48vm}, is typically not installed into an
  11. executable directory such as @file{/usr/local/bin/} on Unix, but in
  12. the Scheme48 library directory, which is, by default on Unix
  13. installations of Scheme48, @file{/usr/local/lib/}. However, both
  14. @command{scheme48} and @command{scheme48vm} share the following
  15. command-line options; the only difference is that @command{scheme48}
  16. has a default @option{-i} argument.
  17. @table @option
  18. @item -h @var{heap-size}
  19. @cindex heap size
  20. @cindex memory size
  21. The size of Scheme48's heap, in cells. By default, the heap size is 3
  22. megacells, or 12 megabytes, permitting 6 megabytes per semispace ---
  23. Scheme48 uses a simple stop & copy garbage collector.@footnote{The
  24. Scheme48 team is also working on a new, generational garbage collector,
  25. but it is not in the standard distribution of Scheme48 yet.} Since
  26. the current garbage collector cannot resize the heap dynamically if it
  27. becomes consistently too full, users on machines with much RAM may be
  28. more comfortable with liberally increasing this option.
  29. @item -s @var{stack-size}
  30. @cindex stack size
  31. The stack size, in cells. The default stack size is 10000 bytes, or
  32. 2500 cells. Note that this is only the size of the stack cache
  33. segment of memory for fast stack frame storage. When this overflows,
  34. there is no error; instead, Scheme48 simply copies the contents of the
  35. stack cache into the heap, until the frames it copied into the heap
  36. are needed later, at which point they are copied back into the stack
  37. cache. The @option{-s} option therefore affects only performance, not
  38. the probability of fatal stack overflow errors.
  39. @item -i @var{image-filename}
  40. The filename of the suspended heap image to resume. When running the
  41. @command{scheme48} executable, the default is the regular Scheme48
  42. image; when running the virtual machine directly, this option must be
  43. passed explicitly. For information on creating custom heap images,
  44. @pxref{Image-building commands}, and also @pxref{Suspending and
  45. resuming heap images}.
  46. @item -a @var{argument} @dots{}
  47. Command-line arguments to pass to the heap image's resumer, rather than
  48. being parsed by the virtual machine. In the usual Scheme48 command
  49. processor image, these arguments are put in a list of strings that will
  50. be the initial @embedref{Focus value, focus value}.
  51. @item -u
  52. @cindex undefined imported bindings
  53. Muffles warnings on startup about undefined imported foreign bindings.
  54. @end table
  55. @cindex batch mode
  56. The usual Scheme48 image may accept an argument of @code{batch}, using
  57. the @option{-a} switch to the virtual machine. This enters Scheme48
  58. in batch mode, which displays no welcoming banner, prints no prompt
  59. for inputs, and exits when an EOF is read. This may be used to run
  60. scripts from the command-line, often in the @embedref{Command
  61. programs, exec language}, by sending text to Scheme48 through Unix
  62. pipes or shell heredocs. For example, this Unix shell command will
  63. load the command program in the file @file{foo.scm} into the exec
  64. language environment and exit Scheme48 when the program returns:
  65. @example
  66. echo ,exec ,load foo.scm | scheme48 -a batch@end example
  67. @noindent
  68. This Unix shell command will load @file{packages.scm} into the module
  69. language environment, open the @code{tests} structure into the user
  70. environment, and call the procedure @code{run-tests} with zero
  71. arguments:
  72. @example
  73. scheme48 -a batch <<END
  74. ,config ,load packages.scm
  75. ,open tests
  76. (run-tests)
  77. END@end example
  78. Scheme48 also supports [SRFI 22] and [SRFI 7] by providing R5RS and
  79. [SRFI 7] script interpreters in the location where Scheme48 binaries
  80. are kept as @command{scheme-r5rs} and @command{scheme-srfi-7}. See the
  81. [SRFI 22] and [SRFI 7] documents for more details. Scheme48's command
  82. processor also has commands for loading [SRFI 7] programs, with or
  83. without a [SRFI 22] script header; @pxref{SRFI 7}.
  84. @subsection Command processor introduction
  85. The Scheme48 command processor is started up on resumption of the usual
  86. Scheme48 image. This is by default what the @command{scheme48} script
  87. installed by Scheme48 does. It will first print out a banner that
  88. contains some general information about the system, which will typically
  89. look something like this:
  90. @example
  91. Welcome to Scheme 48 1.3 (made by root on Sun Jul 10 10:57:03 EDT 2005)
  92. Copyright (c) 1993-2005 by Richard Kelsey and Jonathan Rees.
  93. Please report bugs to scheme-48-bugs@@s48.org.
  94. Get more information at http://www.s48.org/.
  95. Type ,? (comma question-mark) for help.@end example
  96. @noindent
  97. After the banner, it will initiate a REPL (read-eval-print loop). At
  98. first, there should be a simple @samp{>} prompt. The command processor
  99. interprets Scheme code as well as @dfn{commands}. Commands operate the
  100. system at a level above or outside Scheme. They begin with a comma, and
  101. they continue until the end of the line, unless they expect a Scheme
  102. expression argument, which may continue as many lines as desired. Here
  103. is an example of a command invocation:
  104. @example
  105. > ,set load-noisily on@end example
  106. @noindent
  107. This will set the @embedref{Command processor switches,
  108. @code{load-noisily} switch} on.
  109. @strong{Note:} If a command accepts a Scheme expression argument that
  110. is followed by more arguments, all of the arguments after the Scheme
  111. expression must be put on the same line as the last line of the Scheme
  112. expression.
  113. Certain operations, such as breakpoints and errors, result in a
  114. recursive command processor to be invoked. This is known as
  115. @dfn{pushing a command level}. @xref{Command levels}. Also, the
  116. command processor supports an @dfn{object inspector}, an interactive
  117. program for inspecting the components of objects, including continuation
  118. or stack frame objects; the debugger is little more than the inspector,
  119. working on continuations. @xref{Inspector}.
  120. Evaluation of code takes place in the @dfn{interaction environment}.
  121. (This is what R5RS's @code{interaction-environment} returns.)
  122. Initially, this is the @dfn{user environment}, which by default is a
  123. normal R5RS Scheme environment. There are commands that set the
  124. interaction environment and evaluate code in other environments, too;
  125. @pxref{Module commands}.
  126. The command processor's prompt has a variety of forms. As above, it
  127. starts out with as a simple @samp{>}. Several factors can affect the
  128. prompt. The complete form of the prompt is as follows:
  129. @itemize @bullet
  130. @item
  131. It begins with an optional @embedref{Command levels, command level}
  132. number: at the top level, there is no command level number; as command
  133. levels are pushed, the number is incremented, starting at 1.
  134. @item
  135. Optionally, the name of the interaction environment follows the
  136. command level number: if the interaction environment is the user
  137. environment, there is no name printed here; named environments are
  138. printed with their names; unnamed environments (usually created using
  139. the @command{,new-package} command; @pxref{Module commands}) are
  140. printed with their numeric identifiers. If a command level number
  141. preceded an environment name, a space is printed between them.
  142. @item
  143. If the command processor is in the regular REPL mode, it ends with a
  144. @samp{>} and a space before the user input area; if it is in
  145. @embedref{Inspector, inspector mode}, it ends with a @samp{:} and a
  146. space before the user input area.
  147. @end itemize
  148. For example, this prompt denotes that the user is in inspector mode at
  149. command level 3 and that the interaction environment is an environment
  150. named @code{frobozz}:
  151. @example
  152. 3 frobozz: @end example
  153. This prompt shows that the user is in the regular REPL mode at the top
  154. level, but in the @embedref{Module commands, environment for module
  155. descriptions}:
  156. @example
  157. config> @end example
  158. For a complete listing of all the commands in the command processor,
  159. @pxref{Command processor}.