123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!--
- Generated from manual.tex by tex2page, v 2005-03-30
- (running on MzScheme 299.101, unix),
- (c) Dorai Sitaram,
- http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
- -->
- <head>
- <title>
- The Incomplete Scheme 48 Reference Manual for release 1.3
- </title>
- <link rel="stylesheet" type="text/css" href="manual-Z-S.css" title=default>
- <meta name=robots content="noindex,follow">
- </head>
- <body>
- <div id=content>
- <div align=right class=navigation><i>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-3.html">previous</a></span><span>, <a href="manual-Z-H-5.html">next</a></span> page<span>; </span><span><a href="manual-Z-H-2.html#node_toc_start">contents</a></span><span><span>; </span><a href="manual-Z-H-13.html#node_index_start">index</a></span>]</i></div>
- <p></p>
- <a name="node_chap_2"></a>
- <h1 class=chapter>
- <div class=chapterheading><a href="manual-Z-H-2.html#node_toc_node_chap_2">Chapter 2</a></div><br>
- <a href="manual-Z-H-2.html#node_toc_node_chap_2">User's guide</a></h1>
- <p>This chapter details Scheme 48's user interface: its command-line arguments,
- command processor, debugger, and so forth.</p>
- <p>
- </p>
- <a name="node_sec_2.1"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.1">2.1 Command line arguments</a></h2>
- <p>A few command line arguments are processed by Scheme 48 as
- it starts up.</p>
- <p>
- <tt>scheme48</tt>
- [<tt>-i</tt> <i>image</i>]
- [<tt>-h</tt> <i>heapsize</i>]
- [<tt>-a</tt> <i>argument <tt>...</tt></i>]</p>
- <p>
- </p>
- <dl><dt></dt><dd>
- </dd><dt><b><tt>-i</tt> <i>image</i></b></dt><dd>
- specifies a heap image file to resume. This defaults to a heap
- image that runs a Scheme command processor. Heap images are
- created by the <tt>,dump</tt> and <tt>,build commands</tt>, for which see below.<p>
- </p>
- </dd><dt><b><tt>-h</tt> <i>heapsize</i></b></dt><dd>
- specifies how much space should be reserved for allocation.
- <i>Heapsize</i> is in words (where one word = 4 bytes), and covers both
- semispaces, only one of which is in use at any given time (except
- during garbage collection). Cons cells are currently 3 words, so
- if you want to make sure you can allocate a million cons cells,
- you should specify <tt>-h 6000000</tt> (actually somewhat more than this,
- to account for the initial heap image and breathing room).
- The default heap size is 3000000 words. The system will use a
- larger heap if the specified (or default) size is less than
- the size of the image being resumed.<p>
- </p>
- <p>
- </p>
- </dd><dt><b><tt>-a</tt> <i>argument <tt>...</tt></i></b></dt><dd>
- is only useful with images built using <tt>,build</tt>.
- The arguments are passed as a list of strings to the procedure specified
- in the <tt>,build</tt> command as for example:
- <pre class=verbatim>> (define (f a) (for-each display a) (newline) 0)
- > ,build f foo.image
- > ,exit
- % scheme48vm -i foo.image -a mumble "foo x"
- mumblefoo x
- %
- </pre><p>
- </p>
- </dd></dl><p></p>
- <p>
- The usual definition of the <tt>s48</tt> or <tt>scheme48</tt> command is actually a
- shell script that starts up the Scheme 48 virtual machine with a
- <tt>-i <i>imagefile</i></tt>
- specifying the development environment heap image and a
- <tt>-o <i>vm-executable</i></tt> specifying the location of the virtual-machine
- executable (the executable is needed for loading external code on some
- versions of Unix; see section <a href="manual-Z-H-9.html#node_sec_7.4">7.4</a> for more information).
- The file <tt>go</tt> in the Scheme 48 installation source directory is an example
- of such a shell script.</p>
- <p>
- </p>
- <a name="node_sec_2.2"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.2">2.2 Command processor</a></h2>
- <p>When you invoke the default heap image, a command processor starts
- running.
- The command processor acts as both a read-eval-print loop, reading
- expressions, evaluating them, and printing the results, and as
- an interactive debugger and data inspector.
- See Chapter <a href="manual-Z-H-5.html#node_chap_3">3</a> for
- a description of the command processor.</p>
- <p>
- </p>
- <a name="node_sec_2.3"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.3">2.3 Editing</a></h2>
- <p>We recommend running Scheme 48 under GNU Emacs or XEmacs using the
- <tt>cmuscheme48</tt> command package.
- This is in the Scheme 48 distribution's <tt>emacs/</tt> subdirectory and
- is included in XEmacs's <tt>scheme</tt> package.
- It is a variant of the <tt>cmuscheme</tt> library, which
- comes to us courtesy of Olin Shivers, formerly of CMU.
- You might want to put the following in your Emacs init file (<tt>.emacs</tt>):
- </p>
- <pre class=verbatim>(setq scheme-program-name "scheme48")
- (autoload 'run-scheme
- "cmuscheme48"
- "Run an inferior Scheme process."
- t)
- </pre><p>
- The Emacs function <tt>run-scheme</tt> can then be used to start a process
- running the program <tt>scheme48</tt> in a new buffer.
- To make the <tt>autoload</tt> and <tt>(require <tt>...</tt>)</tt> forms work, you will
- also need
- to put the directory containing <tt>cmuscheme</tt> and related files in your
- emacs load-path:
- </p>
- <pre class=verbatim>(setq load-path
- (append load-path '("<i>scheme-48-directory</i>/emacs")))
- </pre><p>
- Further documentation can be found in the files <tt>emacs/cmuscheme48.el</tt> and
- <tt>emacs/comint.el</tt>.</p>
- <p>
- </p>
- <a name="node_sec_2.4"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.4">2.4 Performance</a></h2>
- <p></p>
- <p>
- If you want to generally have your code run faster than it normally
- would, enter <tt>inline-values</tt> mode before loading anything. Otherwise
- calls to primitives (like <tt>+</tt> and <tt>cons</tt>) and in-line procedures
- (like <tt>not</tt> and <tt>cadr</tt>) won't be open-coded, and programs will run
- more slowly.</p>
- <p>
- The system doesn't start in <tt>inline-values</tt> mode by default because the
- Scheme report permits redefinitions of built-in procedures. With
- this mode set, such redefinitions don't work according to the report,
- because previously compiled calls may have in-lined the old
- definition, leaving no opportunity to call the new definition.</p>
- <p>
- <tt>Inline-values</tt> mode is controlled by the <tt>inline-values</tt> switch.
- <tt>,set inline-values</tt> and <tt>,unset inline-values</tt> turn it on and off.</p>
- <p>
- </p>
- <a name="node_sec_2.5"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.5">2.5 Disassembler</a></h2>
- <p>The <tt>,dis</tt> command prints out the disassembled byte codes of a procedure.
- </p>
- <pre class=verbatim>> ,dis cons
- cons
- 0 (protocol 2)
- 2 (pop)
- 3 (make-stored-object 2 pair)
- 6 (return)
- >
- </pre><p>
- The current byte codes are listed in the file <tt>scheme/vm/arch.scm</tt>.
- A somewhat out-of-date description of them can be found in
- [<a href="manual-Z-H-12.html#node_bib_5">5</a>].</p>
- <p>
- The command argument is optional; if unsupplied it defaults to the
- current focus object (<tt>##</tt>).</p>
- <p>
- The disassembler can also be invoked on continuations and templates.</p>
- <p>
- </p>
- <a name="node_sec_2.6"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.6">2.6 Module system</a></h2>
- <p></p>
- <p>
- This section gives a brief description of modules and related entities.
- For detailed information, including a description of the module
- configuration language, see
- chapter <a href="manual-Z-H-6.html#node_chap_4">4</a>.</p>
- <p>
- </p>
- <p>
- A <em>module</em> is an isolated namespace, with visibility of bindings
- controlled by module descriptions written in a special
- configuration language.
- A module may be instantiated as a <em>package</em>, which is an environment
- in which code can be evaluated.
- Most modules are instantiated only once and so have a unique package.
- A <em>structure</em> is a subset of the bindings in a package.
- Only by being included in a structure can a binding be
- made visible in other packages.
- A structure has two parts, the package whose bindings are being exported
- and the set of names that are to be exported.
- This set of names is called an <em>interface</em>.
- A module then has three parts:
- </p>
- <ul>
- <li><p>a set of structures whose bindings are to be visible within the module
- </p>
- <li><p>the source code to be evaluated within the module
- </p>
- <li><p>a set of exported interfaces
- </p>
- </ul><p>
- Instantiating a module produces a package and a set of structures, one for
- each of the exported interfaces.</p>
- <p>
- The following example uses <tt>define-structure</tt> to create a module that
- implements simple cells as pairs, instantiates this module, and binds the
- resulting structure to <tt>cells</tt>.
- The syntax <tt>(export <i>name <tt>...</tt></i>)</tt> creates an interface
- containing <i>name <tt>...</tt></i>.
- The <tt>open</tt> clause lists structures whose bindings are visible
- within the module.
- The <tt>begin</tt> clause contains source code.
- </p>
- <pre class=verbatim>(define-structure cells (export make-cell
- cell-ref
- cell-set!)
- (open scheme)
- (begin (define (make-cell x)
- (cons 'cell x))
- (define cell-ref cdr)
- (define cell-set! set-cdr!)))
- </pre><p></p>
- <p>
- Cells could also have been implemented using the
- record facility described in section <a href="manual-Z-H-7.html#node_sec_5.10">5.10</a>
- and available in structure <tt>define-record-type</tt>.
- </p>
- <pre class=verbatim>(define-structure cells (export make-cell
- cell-ref
- cell-set!)
- (open scheme define-record-types)
- (begin (define-record-type cell :cell
- (make-cell value)
- cell?
- (value cell-ref cell-set!))))
- </pre><p></p>
- <p>
- With either definition the resulting structure can be used in other
- modules by including <tt>cells</tt> in an <tt>open</tt> clause.</p>
- <p>
- The command interpreter is always operating within a particular package.
- Initially this is a package in which only the standard Scheme bindings
- are visible.
- The bindings of other structures can be made visible by using the
- <tt>,open</tt> command described in section <a href="manual-Z-H-5.html#node_sec_3.4">3.4</a> below.</p>
- <p>
- Note that this initial package does not include the configuration language.
- Module code needs to be evaluated in the configuration package, which can
- be done by using the <tt>,</tt>config command:
- </p>
- <pre class=verbatim>> ,config (define-structure cells <tt>...</tt>)
- > ,open cells
- > (make-cell 4)
- '(cell . 4)
- > (define c (make-cell 4))
- > (cell-ref c)
- 4
- </pre><p></p>
- <p>
- </p>
- <a name="node_sec_2.7"></a>
- <h2><a href="manual-Z-H-2.html#node_toc_node_sec_2.7">2.7 Library</a></h2>
- <p>A number of useful utilities are either built in to Scheme 48 or can
- be loaded from an external library. These utilities are not visible
- in the user environment by default, but can be made available with the
- <tt>open</tt> command. For example, to use the <tt>tables</tt> structure, do
- </p>
- <pre class=verbatim>> ,open tables
- >
- </pre><p></p>
- <p>
- If the utility is not already loaded, then the <tt>,open</tt> command will
- load it.
- Or, you can load something explicitly (without opening it) using the
- <tt>load-package</tt> command:
- </p>
- <pre class=verbatim>> ,load-package queues
- > ,open queues
- </pre><p></p>
- <p>
- When loading a utility, the message "Note: optional optimizer not
- invoked" is innocuous. Feel free to ignore it.</p>
- <p>
- See also the package system documentation, in
- chapter <a href="manual-Z-H-6.html#node_chap_4">4</a>.</p>
- <p>
- Not all of the the libraries available in Scheme 48 are described in this
- manual.
- All are listed in files <tt>rts-packages.scm</tt>,
- <tt>comp-packages.scm</tt>, <tt>env-packages.scm</tt>, and
- <tt>more-packages.scm</tt> in the <tt>scheme</tt> directory of the distribution,
- and the bindings they
- export are listed in <tt>interfaces.scm</tt> and
- <tt>more-interfaces.scm</tt> in the same directory.</p>
- <p>
- </p>
- <p>
- </p>
- <div align=right class=navigation><i>[Go to <span><a href="manual.html">first</a>, <a href="manual-Z-H-3.html">previous</a></span><span>, <a href="manual-Z-H-5.html">next</a></span> page<span>; </span><span><a href="manual-Z-H-2.html#node_toc_start">contents</a></span><span><span>; </span><a href="manual-Z-H-13.html#node_index_start">index</a></span>]</i></div>
- </div>
- </body>
- </html>
|