t3x.org / sketchy / sk09.html
SketchyLISP
Reference
  Copyright (C) 2007
Nils M Holm

9 Meta Commands

9.1 Entering Meta Commands

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 SketchyLISP and have no counterparts in R5RS Scheme.

Meta commands must be entered at the SketchyLISP prompt. They will not be recognized in programs.

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.

9.2 ** Variable

** => most recent top-level result

OK, this is not really a meta command, but anyway:

The ** variable is bound to the normal form of the expression most recently entered at the top level. When attempting to evaluate a term that does not have a normal form -- like

(cdr ())

-- the binding of ** remains unchanged:

(cons 'a 'b)
=> (a . b)
**
=> (a . b)
(car ())
* 1: REPL: non-pair in 'car': ()
**
=> (a . b)

9.3 :arrow-mode

:arrow-mode 0|1|2 (default: 0)

Specify how to interpret => operators at the top level.

When this option is set to 0, => is an ordinary symbol name.

When this option is set to 1, 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 =>.

When this option is set to 2, the => operator verifies that the normal form of the most recently evaluated expression is equal to the from on its right. As long as this is the case, nothing special happens:

(cons 'a 'b) => (a . b)   ; everything fine

When the normal form of the lefthand side is not equal to the righthand side of =>, though, an error is reported:

(cons 'a 'b) => foo
=> (a . b)
* 3: REPL: Verification failed; expected: foo

Because this option can break R5RS compliance, it is by default set to zero.

9.4 :closure-form

:closure-form 0|1|2 (default: 0)

The closure form determines how much of a procedure will be printed by write, display and the interpreter itself. By default, only the argument list of a procedure will be included:

(letrec ((x 'foo))
  (lambda (y) (cons y x)))
=> #<procedure (y)>

With :closure-form 1 set, the body of the procedure will be included, too, so the normal form of above expression would print as:

#<procedure (y) (cons x y)>

Using the :closure-form 2, the lexical context of the procedure is included as well:

#<procedure (y) (cons x y) ((x . foo) (cons . #<primitive cons>))>

Setting :closure-form 1 or :closure-form 0 is normally a good idea, because procedures may contain self-referential structures that take infinite time to print.

9.5 :dump-image

: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 -l option of the interpreter:

sketchy -l image-file-name

9.6 :dump-symbols

: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 command also prints the names of all packages created so far. The currently open package is suffixed with the string [open].

9.7 :gc

:gc

Run garbage collection and print some statistics.

9.8 :load

:load file [symbol ...]

Load the content of file.

:load file

is in fact the same as:

(define file (void))
(require "file")

See the description of the require function for further details.

If one or more symbols follow file, they will be silently discarded.

9.9 :quit

:quit

Quit.

9.10 :r5rs-apply

:r5rs-apply on|off (default: on)

When this option is on, the apply function no longer accepts syntax objects (such as and, lambda, etc) as its first argument. When it is off, SketchyLISP allows you to write code like

(apply and '(#t #t #t))

If you want R5RS-compliant behaviour, use :r5rs-apply on.

9.11 :require

:require file [symbol ...]

Load the content of the given file, if the symbol file is not bound.

See the description of the require function for further details.

If one or more symbols follow file, they will be silently discarded.

9.12 :show-license

:show-license

Print the terms of use.

9.13 :show-options

:show-options

List the setting of all options that are tuneable by meta commands.

9.14 :show-version

:show-version

Print version info.

9.15 :statistics

: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 exactl, but do provide a 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.

9.16 :trace

:trace [name]

Turn trace mode on/off. In trace mode, the interpreter will print each application of the specified function. Each trace line will be prefixed with a plus sign (+). To turn off tracing, use :trace without any argument.