Sketchy LISP Reference |
Copyright (C) 2006 Nils M Holm |
[<<Differences to Scheme] | [Contents] [Index] | [References>>] |
A meta command is entered by typing a colon (:) followed by the command itself on an empty line and without any parentheses left open. Meta commands are specific to Sketchy and have no counterparts in R5RS Scheme.
It is normally not necessary to enter the complete name of a
meta command. For example the :show-version
meta
command may be abbreviated as :show-v
or :sv
.
The first variant includes enough characters to make the command
unambiguous, and the second one uses the first character of the
command plus the first character after the dash in it.
Many commands can be abbreviated to one character, so you can type
:l file
instead of :load file
and
:q
to quit.
:arrow-comments on|off (default: off)
Enable or disable arrow comments. When this option is turned on, the
=>
operator introduces a comment, just like ;
.
Arrow comments allow to enter (or paste) expressions of the form
(+ 1 2 3) => 6
without making the interpreter complain about the =>
.
Because this option breaks R5RS compliance, it is disabled by default
(which makes the arrow an ordinary symbol).
Other modes, such as automatic verification, may be added in the future.
:closure-form 0|1|2 (default: 0)
The closure form determines how much of a closure will
be printed by write
, display
and
the interpreter itself. By default, only the argument list
of a closure will be included:
(letrec ((x 'foo)) (lambda (y) (cons y x))) => #<closure (y)>
With :closure-form 1
set, the body of the closure
will be included, too, so the normal form of above expression would
print as:
#<closure (y) (cons x y)>
Using the :closure-form 2
, the lexical context of
the closure is included as well:
#<closure (y) (cons x y) ((x . foo) (cons . #<primitive cons>))>
Setting :closure-form 1
or
:closure-form 0
is normally
a good idea, because closures may contain self-referential structures
that take infinite time to print.
:dump-image file
Dump the complete workspace of the interpreter to the given file. The image can be re-loaded by passing the name of the image file to the interpreter at startup time:
sk image-file-name
:dump-symbols [package]
Dump the symbol table of the given package. If no package name is specified, dump the symbols of the default package. This commands also prints the names of all packages created so far. The currently open package is suffixed with the string [open].
:gc
Run garbage collection and print some statistics.
:load file [symbol ...]
Load the content of file as if typed in at the command line. Reduced expressions will not be echoed. The file name will be converted to all lower case.
If a file that is being loaded using :load
contains
:load
meta commands itself, the files loaded by the
nested meta command will be searched in the directory of the
original file. Here is an example:
:load lib/foo.l
will load the file foo.l from the directory lib. All files loaded by foo.l will be opened inside of lib, so the command
:load bar.l
inside of lib/foo.l will in fact load lib/bar.l.
If one or more symbols follow file, they will be silently discarded. This feature serves documentary purposes.
:quit
Quit.
:r5rs-apply on|off (default: off)
When this option is on, the apply
function no longer
accepts special form handlers (such as and
,
define
, etc) as its first argument. When it is off,
Sketchy allows you to write code like
(apply and '(#t #t #t))
which does not work in R5RS Scheme, because and
is
syntax and not a procedure. If you want R5RS-compliant behaviour,
use :r5rs-apply on
.
:require file [symbol ...]
Load the content of the given file in the same way as :load, but only if the Symbol file is not bound. If a path name is specified in file, only the base name will be used to look up the associated Symbol, so both of the following examples will work:
:require xyz.l :require path/xyz.l
In both cases, a symbol named xyz will be looked up.
This command is intended for loading mutally recursive definitions.
:show-license
Print the terms of use.
:show-version
Print version info.
:statistics on|off (default: off)
Switch statistics mode on or off. In statistics mode, the total number of reduction steps and the number of nodes allocated during the reduction will print after each evaluation. Here is an example:
(cons 'a 'b) => (a . b) 6 reduction steps 25 nodes allocated
These statistics are not easy to interpret and do not provide much more than a rough basis for comparing algorithms. In the above example the six reduction steps are the following:
(cons (quote a) (quote b)) cons (quote a) quote (quote b) quote
The process allocates 25 nodes (which are roughly equivalent to atoms), because the interpreter itself allocates temporary storage during reduction.
:trace [name]
Turn trace mode on/off. In trace mode, the interpreter will
print each application of the specified function after reducing
the arguments but before reducing the function Symbol. Each
trace line will be prefixed with a plus sign (+). To
turn off tracing, use :trace
without any argument.
[<<Differences to Scheme] | [Contents] [Index] | [References>>] |