manual-Z-H-5.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!--
  4. Generated from manual.tex by tex2page, v 20050501
  5. (running on MzScheme 299.400, unix),
  6. (c) Dorai Sitaram,
  7. http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
  8. -->
  9. <head>
  10. <title>
  11. The Incomplete Scheme 48 Reference Manual for release 1.6
  12. </title>
  13. <link rel="stylesheet" type="text/css" href="manual-Z-S.css" title=default>
  14. <meta name=robots content="noindex,follow">
  15. </head>
  16. <body>
  17. <div id=content>
  18. <div align=right class=navigation><i>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-4.html">previous</a></span><span>, <a href="manual-Z-H-6.html">next</a></span> page<span>; &nbsp;&nbsp;</span><span><a href="manual-Z-H-2.html#node_toc_start">contents</a></span><span><span>; &nbsp;&nbsp;</span><a href="manual-Z-H-13.html#node_index_start">index</a></span>]</i></div>
  19. <p></p>
  20. <a name="node_chap_3"></a>
  21. <h1 class=chapter>
  22. <div class=chapterheading><a href="manual-Z-H-2.html#node_toc_node_chap_3">Chapter 3</a></div><br>
  23. <a href="manual-Z-H-2.html#node_toc_node_chap_3">Command processor</a></h1>
  24. <p></p>
  25. <p>
  26. This chapter details Scheme&nbsp;48's command processor, which incorporates
  27. both a read-eval-print loop and an interactive debugger.
  28. At the <tt>&gt;</tt> prompt, you can type either a Scheme form
  29. (expression or definition) or a command beginning with a comma.
  30. In
  31. inspection mode (see section&nbsp;<a href="#node_sec_3.7">3.7</a>)
  32. the prompt changes to <tt>:</tt> and commands
  33. no longer need to be preceded by a comma; input beginning with
  34. a letter or digit is assumed to be a command, not an expression.
  35. In inspection mode the command processor prints out a
  36. menu of selectable components for the current object of interest.</p>
  37. <p>
  38. </p>
  39. <a name="node_sec_3.1"></a>
  40. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.1">3.1&nbsp;&nbsp;Current focus value and <tt>##</tt></a></h2>
  41. <p>The command processor keeps track of a current <em>focus value</em>.
  42. This value is normally the last value returned by a command.
  43. If a command returns multiple values the focus object is a list of the
  44. values.
  45. The focus value is not changed if a command returns no values or
  46. a distinguished `unspecific' value.
  47. Examples of forms that return this unspecific value are definitions,
  48. uses of <tt>set!</tt>, and <tt>(if #f 0)</tt>.
  49. It prints as <tt>#{Unspecific}</tt>.</p>
  50. <p>
  51. The reader used by the command processor reads <tt>##</tt> as a special
  52. expression that evaluates to the current focus object.
  53. </p>
  54. <pre class=verbatim>&gt; (list 'a 'b)
  55. '(a b)
  56. &gt; (car ##)
  57. 'a
  58. &gt; (symbol-&gt;string ##)
  59. &quot;a&quot;
  60. &gt; (if #f 0)
  61. #{Unspecific}
  62. &gt; ##
  63. &quot;a&quot;
  64. &gt;
  65. </pre><p></p>
  66. <p>
  67. </p>
  68. <a name="node_sec_3.2"></a>
  69. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.2">3.2&nbsp;&nbsp;Command levels</a></h2>
  70. <p>If an error, keyboard interrupt, or other breakpoint occurs, or the
  71. <tt>,push</tt> command is used, the command
  72. processor invokes a recursive copy of itself, preserving the dynamic state of
  73. the program when the breakpoint occured.
  74. The recursive invocation creates a new <em>command level</em>.
  75. The command levels form a stack with the current level at the top.
  76. The command prompt indicates the number of stopped levels below the
  77. current one: <tt>&gt;</tt> or <tt>:</tt> for the
  78. base level and <tt><i>n</i>&gt;</tt> or <tt><i>n</i>:</tt> for all other levels,
  79. where <i>n</i> is the command-level nesting depth.
  80. The <tt>levels</tt> setting
  81. described below can be used to disable the automatic pushing of new levels.</p>
  82. <p>
  83. The command processor's evaluation package and the value of the
  84. current focus value are local to each command level.
  85. They are preserved when a new level is pushed and restored when
  86. it is discarded.
  87. The settings of all other settings are shared by all command levels.</p>
  88. <p>
  89. </p>
  90. <dl><dt></dt><dd>
  91. </dd><dt></dt><dd>&lt;eof&gt;<br>
  92. Discards the current command level and resumes running the level down.
  93. &lt;eof&gt; is usually
  94. control-<tt>D</tt> at a Unix shell or control-<tt>C</tt> control-<tt>D</tt> using
  95. the Emacs <tt>cmuscheme48</tt> library.<p>
  96. </p>
  97. </dd><dt></dt><dd><tt>,pop</tt><br>
  98. The same as &lt;eof&gt;.<p>
  99. </p>
  100. </dd><dt></dt><dd><tt>,proceed [<i>exp</i> <tt>...</tt></tt>]<br>
  101. Proceed after an interrupt or error, resuming the next command
  102. level down, delivering the values of <i>exp&nbsp;<tt>...</tt></i> to the continuation.
  103. Interrupt continuations discard any returned values.
  104. <tt>,Pop</tt> and <tt>,proceed</tt> have the same effect after an interrupt
  105. but behave differently after errors.
  106. <tt>,Proceed</tt> restarts the erroneous computation from the point where the
  107. error occurred (although not all errors are proceedable) while
  108. <tt>,pop</tt> (and &lt;eof&gt;) discards it and prompts for
  109. a new command.<p>
  110. </p>
  111. </dd><dt></dt><dd><tt>,push</tt><br>
  112. Pushes a new command level on above the current one.
  113. This is useful if the <tt>levels</tt> setting has been used
  114. to disable the automatic pushing of new levels for errors and interrupts.<p>
  115. </p>
  116. </dd><dt></dt><dd><tt>,reset [<i>number</i>]</tt><br>
  117. Pops down to a given level and restarts that level.
  118. <i>Number</i> defaults to zero, <tt>,reset</tt> restarts the command
  119. processor, discarding all existing levels.<p>
  120. </p>
  121. </dd></dl><p></p>
  122. <p>
  123. Whenever moving to an existing level, either by sending
  124. an &lt;eof&gt;
  125. or by using <tt>,reset</tt> or the other commands listed above,
  126. the command processor runs all of the <tt>dynamic-wind</tt> ``after'' thunks
  127. belonging to stopped computations on the discarded level(s).</p>
  128. <p>
  129. </p>
  130. <a name="node_sec_3.3"></a>
  131. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.3">3.3&nbsp;&nbsp;Logistical commands</a></h2>
  132. <p></p>
  133. <dl><dt></dt><dd>
  134. </dd><dt></dt><dd><tt>,load <i>filename <tt>...</tt></i></tt><br>
  135. Loads the named Scheme source file(s).
  136. Easier to type than <tt>(load &quot;<i>filename</i>&quot;)</tt> because you don't have to
  137. shift to type the parentheses or quote marks.
  138. (However, it is still possible to specify a filename as a Scheme
  139. string literal, with quote marks -- you'll need this for filenames
  140. containing whitespace.)
  141. Also, it works in
  142. any package, unlike <tt>(load &quot;<i>filename</i>&quot;)</tt>, which will work only
  143. work in packages in which the variable <tt>load</tt> is defined appropriately.<p>
  144. </p>
  145. </dd><dt></dt><dd><tt>,exit [<i>exp</i>]</tt>
  146. Exits back out to shell (or executive or whatever invoked Scheme&nbsp;48
  147. in the first place).
  148. <i>Exp</i> should evaluate to an integer. The
  149. integer is returned to the calling program.
  150. The default value of <i>exp</i> is zero, which, on Unix,
  151. is generally interpreted as success.
  152. </dd></dl><p></p>
  153. <p>
  154. </p>
  155. <a name="node_sec_3.4"></a>
  156. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.4">3.4&nbsp;&nbsp;Module commands</a></h2>
  157. <p></p>
  158. <p>
  159. There are many commands related to modules.
  160. Only the most commonly used module commands are described here;
  161. documentation for the
  162. rest can be found in section&nbsp;<a href="manual-Z-H-6.html#node_sec_4.8">4.8</a>.
  163. There is also
  164. a brief description of modules, structures, and packages in section&nbsp;<a href="manual-Z-H-4.html#node_sec_2.6">2.6</a> below.</p>
  165. <p>
  166. </p>
  167. <dl><dt></dt><dd>
  168. </dd><dt></dt><dd><tt>,open <i>structure <tt>...</tt></i></tt><br>
  169. Makes the bindings in the <i>structure</i>s visible in the current package.
  170. The packages associated with the <i>structure</i>s will be loaded if
  171. this has not already been done (the <tt>ask-before-loading</tt> setting
  172. can be used disable the automatic loading of packages).<p>
  173. </p>
  174. </dd><dt></dt><dd><tt>,config [<i>command</i>]</tt><br>
  175. Executes <i>command</i> in the <tt>config</tt> package, which includes
  176. the module configuration language.
  177. For example, use
  178. <pre class=verbatim>,config ,load <i>filename</i>
  179. </pre><p>
  180. to load a file containing module definitions.
  181. If no <i>command</i> is given, the <tt>config</tt> package becomes the
  182. execution package for future commands.</p>
  183. <p>
  184. </p>
  185. </dd><dt></dt><dd><tt>,user [<i>command</i>]</tt> <br>
  186. This is similar to the <tt>,config</tt>. It
  187. moves to or executes a command in the user package (which is the
  188. default package when the Scheme&nbsp;48 command processor starts).<p>
  189. </p>
  190. </dd></dl><p></p>
  191. <p>
  192. </p>
  193. <a name="node_sec_3.5"></a>
  194. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.5">3.5&nbsp;&nbsp;Debugging commands</a></h2>
  195. <p></p>
  196. <p>
  197. </p>
  198. <dl><dt></dt><dd>
  199. </dd><dt></dt><dd><tt>,preview</tt><br>
  200. Somewhat like a backtrace, but because of tail recursion you see
  201. less than you might in debuggers for some other languages.
  202. The stack to display is chosen as follows:
  203. <ol>
  204. <li><p>If the current focus object is a continuation or a thread,
  205. then that continuation or thread's stack is displayed.
  206. </p>
  207. <li><p>Otherwise, if the current command level was initiated because of
  208. a breakpoint in the next level down, then the stack at that
  209. breakpoint is displayed.
  210. </p>
  211. <li><p>Otherwise, there is no stack to display and a message is printed
  212. to that effect.
  213. </p>
  214. </ol><p>
  215. One line is printed out for each continuation on the chosen stack,
  216. going from top to bottom.</p>
  217. <p>
  218. </p>
  219. </dd><dt></dt><dd><tt>,run <i>exp</i></tt><br>
  220. Evaluate <i>exp</i>, printing the result(s) and making them
  221. (or a list of them, if <i>exp</i> returns multiple results)
  222. the new focus object.
  223. The <tt>,run</tt> command is useful when writing
  224. command programs, which are described in section&nbsp;<a href="#node_sec_3.8">3.8</a> below.<p>
  225. </p>
  226. </dd><dt></dt><dd><tt>,trace <i>name</i> <tt>...</tt></tt><br>
  227. Start tracing calls to the named procedure or procedures.
  228. With no arguments, displays all procedures currently traced.
  229. This affects the binding of <i>name</i>, not the behavior of the
  230. procedure that is its current value. <i>Name</i> is redefined
  231. to be a procedure that prints a message,
  232. calls the original value of <i>name</i>, prints another
  233. message, and finally passes along the value(s) returned by the
  234. original procedure.<p>
  235. </p>
  236. </dd><dt></dt><dd><tt>,untrace <i>name</i> <tt>...</tt></tt><br>
  237. Stop tracing calls to the named procedure or procedures.
  238. With no argument, stop tracing all calls to all procedures.<p>
  239. </p>
  240. </dd><dt></dt><dd><tt>,condition</tt><br>
  241. The <tt>,condition</tt> command displays the condition object
  242. describing the error or interrupt that initiated the current
  243. command level. The condition object becomes the current focus
  244. value. This is particularly useful in conjunction with
  245. the inspector. For example, if a procedure is passed the wrong number of
  246. arguments, do <tt>,condition</tt> followed by
  247. <tt>,inspect</tt> to inspect the
  248. procedure and its arguments.<p>
  249. </p>
  250. </dd><dt></dt><dd><tt>,bound? <i>name</i></tt><br>
  251. Display the binding of <i>name</i>, if there is one, and otherwise
  252. prints `<tt>Not bound</tt>'.<p>
  253. </p>
  254. </dd><dt></dt><dd><tt>,expand <i>form</i></tt>
  255. </dd><dt></dt><dd><tt>,expand-all <i>form</i></tt><br>
  256. Show macro expansion of <i>form</i>, if any.
  257. <tt>,expand</tt> performs a single macro expansion while
  258. <tt>,expand-all</tt> fully expands all macros in <i>form</i>.<p>
  259. </p>
  260. </dd><dt></dt><dd><tt>,where <i>procedure</i></tt><br>
  261. Display name of file containing <i>procedure</i>'s source code.
  262. </dd></dl><p></p>
  263. <p>
  264. </p>
  265. <a name="node_sec_3.6"></a>
  266. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.6">3.6&nbsp;&nbsp;Settings</a></h2>
  267. <p>There are a number of settings that control the behavior of the
  268. command processor; most of them are booleans.
  269. They can be set using the <tt>,set</tt> and <tt>,unset</tt> commands.</p>
  270. <p>
  271. </p>
  272. <dl><dt></dt><dd>
  273. </dd><dt></dt><dd><tt>,set <i>setting</i> [on | off | literal | ?]</tt><br>
  274. This sets the value of setting <i>setting</i>.
  275. For a boolean setting, the second argument must be <tt>on</tt> or
  276. <tt>off</tt>; it then defaults to <tt>on</tt>.
  277. Otherwise, the value must be a literal, typically a posititive number.
  278. If the second argument is <tt>?</tt> the value of <i>setting</i> is
  279. is displayed and not changed.
  280. Doing <tt>,set ?</tt> will display a list of the setting and
  281. their current values.<p>
  282. </p>
  283. </dd><dt></dt><dd><tt>,unset <i>setting</i></tt><br>
  284. <tt>,unset <i>setting</i></tt> is the same as
  285. <tt>,set <i>setting</i> off</tt>.
  286. </dd></dl><p></p>
  287. <p>
  288. The settings are as follows:
  289. </p>
  290. <dl><dt></dt><dd>
  291. </dd><dt></dt><dd><tt>batch</tt> (boolean)<br>
  292. In `batch mode' any error or interrupt that comes up will cause
  293. Scheme&nbsp;48 to exit immediately with a non-zero exit status. Also,
  294. the command processor doesn't print prompts. Batch mode is
  295. off by default.<p>
  296. </p>
  297. <p>
  298. </p>
  299. </dd><dt></dt><dd><tt>levels</tt> (boolean)<br>
  300. Enables or disables the automatic pushing of a new command level when
  301. an error, interrupt, or other breakpoint occurs.
  302. When enabled (the default), breakpoints push a new command level,
  303. and &lt;eof&gt; (see above)
  304. or <tt>,reset</tt> is required to return to top level. The effects of
  305. pushed command levels include:
  306. <ul>
  307. <li><p>a longer prompt
  308. </p>
  309. <li><p>retention of the continuation in effect at the point of errors
  310. </p>
  311. <li><p>confusion among some newcomers
  312. </p>
  313. </ul><p>
  314. With <tt>levels</tt> disabled one must issue a
  315. <tt>,push</tt> command immediately
  316. following an error in order to retain the error continuation for
  317. debugging purposes; otherwise the continuation is lost as soon as
  318. the focus object changes. If you don't know anything about the
  319. available debugging tools, then levels might as well be disabled.</p>
  320. <p>
  321. </p>
  322. </dd><dt></dt><dd><tt>break-on-warnings</tt> (boolean)<br>
  323. Enter a new command level when a warning is produced, just as
  324. when an error occurs. Normally warnings only result in a displayed
  325. message and the program does not stop executing.<p>
  326. </p>
  327. </dd><dt></dt><dd><tt>ask-before-loading</tt> (boolean)<br>
  328. If on, the system will ask before loading modules that are arguments
  329. to the <tt>,open</tt> command. <tt>Ask-before-loading</tt> is off by
  330. default.
  331. <pre class=verbatim>&gt; ,set ask-before-loading
  332. will ask before loading modules
  333. &gt; ,open random
  334. Load structure random (y/n)? y
  335. &gt;
  336. </pre><p></p>
  337. <p>
  338. </p>
  339. </dd><dt></dt><dd><tt>load-noisily</tt> (boolean)<br>
  340. When on, the system will print out the names of modules and files
  341. as they are loaded. <tt>load-noisily</tt> is off by default.
  342. <pre class=verbatim>&gt; ,set load-noisily
  343. will notify when loading modules and files
  344. &gt; ,open random
  345. [random /usr/local/lib/scheme48/big/random.scm]
  346. &gt;
  347. </pre><p></p>
  348. <p>
  349. </p>
  350. </dd><dt></dt><dd><tt>inline-values</tt> (boolean)<br>
  351. This controls whether or not the compiler is allowed to substitute
  352. variables' values in-line.
  353. When <tt>inline-values</tt> mode is on,
  354. some Scheme procedures will be substituted in-line; when it is off,
  355. none will.
  356. Section&nbsp;<a href="manual-Z-H-4.html#node_sec_2.4">2.4</a>
  357. has more information.<p>
  358. </p>
  359. </dd><dt></dt><dd><tt>inspector-menu-limit</tt> (positive integer)<br>
  360. This controls how many items the displayed portion of the inspector
  361. menu contains at most. (See Section&nbsp;<a href="#node_sec_3.7">3.7</a>.)<p>
  362. </p>
  363. </dd><dt></dt><dd><tt>inspector-writing-depth</tt> (positive integer)<br>
  364. This controls the maximum depth to which the inspector
  365. prints values. (See Section&nbsp;<a href="#node_sec_3.7">3.7</a>.)<p>
  366. </p>
  367. </dd><dt></dt><dd><tt>inspector-writing-length</tt> (positive integer)<br>
  368. This controls the maximum length to which the inspector
  369. prints values. (See Section&nbsp;<a href="#node_sec_3.7">3.7</a>.)<p>
  370. </p>
  371. </dd><dt></dt><dd><tt>condition-writing-depth</tt> (positive integer)<br>
  372. This controls the maximum depth to which conditions
  373. are printed.<p>
  374. </p>
  375. </dd><dt></dt><dd><tt>condition-writing-length</tt> (positive integer)<br>
  376. This controls the maximum length to which conditions
  377. are printed.<p>
  378. </p>
  379. </dd><dt></dt><dd><tt>trace-writing-length</tt> (positive integer)<br>
  380. This controls the maximum length to which tracing
  381. prints procedure calls.
  382. </dd></dl><p></p>
  383. <p>
  384. </p>
  385. <a name="node_sec_3.7"></a>
  386. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.7">3.7&nbsp;&nbsp;Inspection mode</a></h2>
  387. <p></p>
  388. <p>
  389. There is a data inspector available via the <tt>,inspect</tt> and
  390. <tt>,debug</tt> commands.
  391. The inspector is particularly useful with procedures, continuations,
  392. and records.
  393. The command processor can be taken out of inspection mode by
  394. using the <tt>q</tt> command.
  395. When in inspection mode, input that begins with
  396. a letter or digit is read as a command, not as an expression.
  397. To see the value of a variable or number, do <tt>(begin <i>exp</i>)</tt>
  398. or use the <tt>,run <i>exp</i></tt> command.</p>
  399. <p>
  400. In inspection mode the command processor prints out a
  401. menu of selectable components for the current focus object.
  402. To inspect a particular component, just type the corresponding number in
  403. the menu.
  404. That component becomes the new focus object.
  405. For example:
  406. </p>
  407. <pre class=verbatim>&gt; ,inspect '(a (b c) d)
  408. (a (b c) d)
  409. [0] a
  410. [1] (b c)
  411. [2] d
  412. : 1
  413. (b c)
  414. [0] b
  415. [1] c
  416. :
  417. </pre><p></p>
  418. <p>
  419. When a new focus object is selected the previous one is pushed onto a
  420. stack.
  421. You can pop the stack, reverting to the previous object, with
  422. the <tt>u</tt> command, or use the <tt>stack</tt> command to move to
  423. an earlier object.</p>
  424. <p>
  425. </p>
  426. <p>
  427. Commands useful when in inspection mode:
  428. </p>
  429. <ul>
  430. <li><p><tt>u</tt> (up) pop object stack
  431. </p>
  432. <li><p><tt>m</tt> (more) print more of a long menu
  433. </p>
  434. <li><p><tt>(<tt>...</tt>)</tt> evaluate a form and select result
  435. </p>
  436. <li><p><tt>q</tt> quit
  437. </p>
  438. <li><p><tt>template</tt> select a closure or continuation's template
  439. (Templates are the static components of procedures; these are found
  440. inside of procedures and continuations, and contain the quoted
  441. constants and top-level variables referred to by byte-compiled code.)
  442. </p>
  443. <li><p><tt>d</tt> (down) move to the next continuation
  444. (current object must be a continuation)
  445. </p>
  446. <li><p><tt>menu</tt> print the selection menu for the focus object
  447. </p>
  448. </ul><p></p>
  449. <p>
  450. Multiple selection commands (<tt>u</tt>, <tt>d</tt>, and menu indexes)
  451. may be put on a single line.</p>
  452. <p>
  453. </p>
  454. <p>
  455. All ordinary commands are available when in inspection mode.
  456. Similarly, the inspection commands can be used when not in inspection
  457. mode.
  458. For example:
  459. </p>
  460. <pre class=verbatim>&gt; (list 'a '(b c) 'd)
  461. '(a (b c) d)
  462. &gt; ,1
  463. '(b c)
  464. &gt; ,menu
  465. [0] b
  466. [1] c
  467. &gt;
  468. </pre><p></p>
  469. <p>
  470. If the current command level was initiated because of
  471. a breakpoint in the next level down, then
  472. <tt>,debug</tt> will invoke the inspector on the
  473. continuation at the point of the error.
  474. The <tt>u</tt> and <tt>d</tt> (up and down)
  475. commands then make the inspected-value stack look like a conventional stack
  476. debugger, with continuations playing the role of stack frames. <tt>D</tt> goes
  477. to older or deeper continuations (frames), and <tt>u</tt> goes back up to more
  478. recent ones.</p>
  479. <p>
  480. </p>
  481. <a name="node_sec_3.8"></a>
  482. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.8">3.8&nbsp;&nbsp;Command programs</a></h2>
  483. <p></p>
  484. <p>
  485. The <tt>exec</tt> package contains procedures that are used
  486. to execute the command processor's commands.
  487. A command <tt>,<i>foo</i></tt> is executed by applying the value of
  488. the identifier <i>foo</i> in the <tt>exec</tt> package to
  489. the (suitably parsed) command arguments.</p>
  490. <p>
  491. </p>
  492. <dl><dt></dt><dd>
  493. </dd><dt></dt><dd><tt>,exec [<i>command</i>]</tt><br>
  494. Evaluate <i>command</i> in the <tt>exec</tt> package.
  495. For example, use
  496. <pre class=verbatim>,exec ,load <i>filename</i>
  497. </pre><p>
  498. to load a file containing commands.
  499. If no <i>command</i> is given, the <tt>exec</tt> package becomes the
  500. execution package for future commands.
  501. </p>
  502. </dd></dl><p></p>
  503. <p>
  504. The required argument types are as follows:
  505. </p>
  506. <ul>
  507. <li><p>filenames should be strings
  508. </p>
  509. <li><p>other names and identifiers should be symbols
  510. </p>
  511. <li><p>expressions should be s-expressions
  512. </p>
  513. <li><p>commands (as for <tt>,config</tt> and <tt>,exec</tt> itself)
  514. should be lists of the form
  515. <tt>(<i>command-name</i> <i>argument</i> <i>...</i>)</tt>
  516. where <i>command-name</i> is a symbol.
  517. </p>
  518. </ul><p></p>
  519. <p>
  520. For example, the following two commands are equivalent:
  521. </p>
  522. <pre class=verbatim>,config ,load my-file.scm
  523. ,exec (config '(load &quot;my-file.scm&quot;))
  524. </pre><p></p>
  525. <p>
  526. The file <tt>scheme/vm/load-vm.scm</tt> in the source directory contains an
  527. example of an <tt>exec</tt> program.</p>
  528. <p>
  529. </p>
  530. <a name="node_sec_3.9"></a>
  531. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.9">3.9&nbsp;&nbsp;Building images</a></h2>
  532. <p></p>
  533. <dl><dt></dt><dd>
  534. </dd><dt></dt><dd><tt>,dump <i>filename</i> [<i>identification</i>]</tt><br>
  535. Writes the current heap out to a file, which can then be run using the
  536. virtual machine. The new image file includes the command processor.
  537. If present, <i>identification</i>
  538. should be a string (written with double quotes); this string will
  539. be part of the greeting message as the image starts up.<p>
  540. </p>
  541. </dd><dt></dt><dd><tt>,build <i>exp</i> <i>filename</i> [<i>option <tt>...</tt></i>]</tt><br>
  542. Like <tt>,dump</tt>, except that the image file contains the value of
  543. <i>exp</i>, which should be a procedure of one argument, instead of
  544. the command processor. When
  545. <i>filename</i> is resumed, that procedure will be invoked on the VM's
  546. <tt>-a</tt> arguments, which are passed as a list of OS strings (see
  547. section&nbsp;<a href="manual-Z-H-7.html#node_sec_5.15">5.15</a>. The
  548. procedure should return an integer which is
  549. returned to the program that invoked the VM. The command
  550. processor and debugging system are not included in the image
  551. (unless you go to some effort to preserve them, such as retaining
  552. a continuation).<p>
  553. If <tt>no-warnings</tt> appears as an <i>option</i> after the file
  554. name, no warnings about undefined external bindings
  555. (see Section&nbsp;<a href="manual-Z-H-10.html#node_sec_8.2">8.2</a>) will be printed upon
  556. resuming the image. This is useful when the definitions of
  557. external bindings appear in shared objects that are only loaded
  558. after the resumption of the image.</p>
  559. <p>
  560. Doing <tt>,flush</tt> before building an image will reduce the amount
  561. of debugging information in the image, making for a smaller
  562. image file, but if an error occurs, the error message may be less
  563. helpful. Doing <tt>,flush source maps</tt> before loading any programs
  564. used in the image will make it still smaller.
  565. See section&nbsp;<a href="#node_sec_3.10">3.10</a>
  566. for more information.</p>
  567. <p>
  568. </p>
  569. </dd></dl><p></p>
  570. <p>
  571. </p>
  572. <a name="node_sec_3.10"></a>
  573. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.10">3.10&nbsp;&nbsp;Resource query and control</a></h2>
  574. <p>.</p>
  575. <p>
  576. </p>
  577. <dl><dt></dt><dd>
  578. </dd><dt></dt><dd><tt>,time <i>exp</i></tt><br>
  579. Measure execution time.<p>
  580. </p>
  581. </dd><dt></dt><dd><tt>,collect</tt><br>
  582. Invoke the garbage collector. Ordinarily this happens
  583. automatically, but the command tells how much space is available
  584. before and after the collection.<p>
  585. </p>
  586. </dd><dt></dt><dd><tt>,keep <i>kind</i></tt>
  587. </dd><dt></dt><dd><tt>,flush <i>kind</i></tt><br>
  588. These control the amount of debugging information retained after
  589. compiling procedures. This information can consume a fair amount
  590. of space. <i>kind</i> is one of the following:
  591. <ul>
  592. <li><p><tt>maps</tt> - environment maps (local variable names, for inspector)
  593. </p>
  594. <li><p><tt>source</tt> - source code for continuations (displayed by inspector)
  595. </p>
  596. <li><p><tt>names</tt> - procedure names (as displayed by <tt>write</tt> and in error
  597. messages)
  598. </p>
  599. <li><p><tt>files</tt> - source file names
  600. </p>
  601. </ul><p>
  602. These commands refer to future compilations only, not to procedures
  603. that already exist. To have any effect, they must be done before
  604. programs are loaded. The default is to keep all four types.
  605. </p>
  606. <p>
  607. </p>
  608. </dd><dt></dt><dd><tt>,flush</tt><br>
  609. The flush command with no argument deletes the database of names
  610. of initial procedures. Doing <tt>,flush</tt> before a <tt>,build</tt> or
  611. <tt>,dump</tt>
  612. will make the resulting image significantly smaller, but will
  613. compromise the information content of many error
  614. messages.
  615. </dd></dl><p></p>
  616. <p>
  617. </p>
  618. <a name="node_sec_3.11"></a>
  619. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.11">3.11&nbsp;&nbsp;Threads</a></h2>
  620. <p></p>
  621. <p>
  622. Each command level has its own set of threads. These threads are suspended
  623. when a new level is entered and resumed when the owning level again becomes
  624. the current level.
  625. A thread that raises an error is not resumed unless
  626. explicitly restarted using the <tt>,proceed</tt> command.
  627. In addition to any threads spawned by the user, each level has a thread
  628. that runs the command processor on that level.
  629. A new command-processor thread is started if the current one
  630. dies or is terminated.
  631. When a command level is abandoned for a lower level, or when
  632. a level is restarted using <tt>,reset</tt>, all of the threads on that
  633. level are terminated and any <tt>dynamic-wind</tt> ``after'' thunks are run.</p>
  634. <p>
  635. The following commands are useful when debugging multithreaded programs:
  636. </p>
  637. <dl><dt></dt><dd>
  638. </dd><dt></dt><dd><tt>,resume [<i>number</i>]</tt><br>
  639. Pops out to a given level and resumes running all threads at that level.
  640. <i>Number</i> defaults to zero.<p>
  641. </p>
  642. </dd><dt></dt><dd><tt>,threads</tt><br>
  643. Invokes the inspector on a list of the threads running at the
  644. next lower command level.<p>
  645. </p>
  646. </dd><dt></dt><dd><tt>,exit-when-done [<i>exp</i>]</tt><br>
  647. Waits until all user threads have completed and then
  648. exits back out to shell (or executive or whatever invoked Scheme&nbsp;48
  649. in the first place).
  650. <i>Exp</i> should evaluate to an integer which is then
  651. returned to the calling program.
  652. <p>
  653. </p>
  654. <p>
  655. </p>
  656. </dd></dl><p></p>
  657. <p>
  658. </p>
  659. <a name="node_sec_3.12"></a>
  660. <h2><a href="manual-Z-H-2.html#node_toc_node_sec_3.12">3.12&nbsp;&nbsp;Quite obscure</a></h2>
  661. <p></p>
  662. <dl><dt></dt><dd>
  663. </dd><dt></dt><dd><tt>,go <i>exp</i></tt><br>
  664. This is like <tt>,exit <i>exp</i></tt> except that the evaluation of <i>exp</i>
  665. is tail-recursive with respect to the command processor. This
  666. means that the command processor itself can probably be GC'ed,
  667. should a garbage collection occur in the execution of <i>exp</i>.
  668. If an error occurs Scheme&nbsp;48 will exit with a non-zero value.<p>
  669. </p>
  670. </dd><dt></dt><dd><tt>,translate <i>from</i> <i>to</i></tt><br>
  671. For <tt>load</tt> and the <tt>,load</tt> command
  672. (but not for <tt>open-{in|out}put-file</tt>), file
  673. names beginning with the string <i>from</i> will be changed so that the
  674. initial <i>from</i> is replaced by the string <i>to</i>. E.g.
  675. <pre class=verbatim><tt>,translate /usr/gjc/ /zu/gjc/</tt>
  676. </pre><p>
  677. will cause <tt>(load &quot;/usr/gjc/foo.scm&quot;)</tt> to have the same effect as
  678. <tt>(load &quot;/zu/gjc/foo.scm&quot;)</tt>.
  679. </p>
  680. <p>
  681. </p>
  682. </dd><dt></dt><dd><tt>,from-file <i>filename</i> <i>form</i> <tt>...</tt> ,end</tt><br>
  683. This is used by the <tt>cmuscheme48</tt> Emacs library to indicate the file
  684. from which the <i>form</i>s came. <i>Filename</i> is then used by the
  685. command processor to determine the package in which the <i>form</i>s
  686. are to be evaluated.
  687. </dd></dl><p></p>
  688. <p>
  689. </p>
  690. <div align=right class=navigation><i>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-4.html">previous</a></span><span>, <a href="manual-Z-H-6.html">next</a></span> page<span>; &nbsp;&nbsp;</span><span><a href="manual-Z-H-2.html#node_toc_start">contents</a></span><span><span>; &nbsp;&nbsp;</span><a href="manual-Z-H-13.html#node_index_start">index</a></span>]</i></div>
  691. <p></p>
  692. </div>
  693. </body>
  694. </html>