SXM (1)

v1.1 (December 9, 2001)

NAME

sxm - runtime for the Scheme language
sxi - interpreter for the Scheme language

SYNOPSIS

sxm [ optionsfile ...
sxi  file ...

DESCRIPTION

Sxm (a.k.a. CXEMA) is an implementation of the Scheme programming language. It consists of two programs: the runtime module (sxm) providing the core functionality and the interpreter front-end (sxi) that implements the full language on top of the runtime and provides the traditional interactive interface. The language supported by sxi conforms to ANSI standard of Scheme and extended definition of Scheme in R5RS report. Sxi also supports some of more recent SRFI extensions and many features found in the Chez Scheme implementation.

Normally the user invokes sxi optionally specifying one or more source files in the command line. The interpreter loads the input files in order via a standard load procedure and then enters the interactive mode (read-eval-print loop) interpreting the standard input. It prompts the user with the right angle bracket at the beginning of the input line and waits until the complete expression is entered. Than the interpreter compiles the expression, evaluates it and prints the result. The loop is repeated until the end-of-file is reached.

If the "-s" option is specified and the interpreter exits normally via (exit) or by reaching the end of the standard input, the last state of the Scheme system (heap image) is saved to the file specified after the "-s" option. Heap images preserve all runtime data created during the session except for the input state of file ports left opened at the end of the session. To restore the state of the Scheme session saved in a heap image you may run sxm specifying the image file with the "-h" option. Running an image file directly has the same effect (you have to make sure that runtime module is at its standard location to make this work). The interpreter itself is also a heap image built from source files by sxm installer.

If you run sxm with no heap image specified, it will also attempt to load all input files and then enter the read-eval-print loop. However, the language sxm understands is not a full Scheme; its only purpose is to facilitate bootstrapping of the full interpreter.

OPTIONS

Sxm recognizes the following command line options:

-h  file load heap image from file
-s  file save heap image on normal exit in file
-t initialize image for interactive use (ignored if "-h")
-e exit after loading files on command line (ignored if "-h")
-- treat rest of command line as file names (not options)

If the "-h" option is not present, sxm loads every file on the command line. This is usually done as a part of the bootstrap process; the files are used to upgrade the interpreter from "core" to full Scheme. In this scenario, the "-e" option tells sxm to exit after the last input file is loaded and the "-s" option specifies the name of the resulting image file. If the image is intended for interactive use, it is also useful to specify the "-t" option. This will turn on support for session transcripts by forcing the saved image to use special console ports when it detects that the standard input and output streams are attached to a terminal.

If the "-h" option is specified, sxm restores the state saved in the specified image file. In this case, the "-t" and "-e" options are ignored and the files on the command line are loaded by a standard load procedure. On normal exit, if the "-s" option is specified, the state of the system is saved as a new heap image file.

It is possible to prevent sxm from interpreting command line arguments as options by prefixing them with the "--" option. All arguments following the "--" option are treated as files, not options.

The execution of heap images starts with the call of the standard startup procedure stored as a value of the scheme-start parameter. To change the behavior of an image at startup time, a new procedure can be installed before the image is written to the file. Custom startup procedures may interpret command line arguments instead of treating them as files and replace standard read-eval-print loop with a non-interactive calculation.

ANSI/R5RS CONFORMANCE

The only known incompatibility with ANSI and R5RS Scheme specifications is the special treatment of assignments to certain built-in procedures. Sxm inlines calls to a dozen of the most frequently used standard procedures like car and cdr and, in an attempt to to preserve consistency, makes top-level bindings of inline procedures immutable.

SRFI SUPPORT

Sxm supports the following SRFIs:

SRFI 0 Feature-based conditional expansion construct
SRFI 6 Basic String Ports
SRFI 8 receive: Binding to multiple values
SRFI 9 Defining Record Types
SRFI 11 Syntax for receiving multiple values
SRFI 16 Syntax for procedures of variable arity

COMPATIBILITY WITH CHEZ SCHEME

Sxm provides numerous language and programming environment extensions found in Chez Scheme v.6. There are still a lot of incompatibilities, however. They are listed below in Chez Scheme User's Guide order and with the corresponding section numbers:

1.1 the only supported reader extensions are square brackets ([]), single escape char for symbols (\), notation for boxes (#&), multiline comments (#| |#), and two peculiar symbols (1+ and -1+).
2.3, 2.4 no interactive/noninteractive inspectors; inspect can only be used to display stack contents
3 no foreign interface except for system and process
5.2 sxm has cheap but unsafe escaping continuations (call/esc) instead of Chez Scheme's cheap and safe one-shot continuations (call/1cc)
6.8 only identifiers are supported as field specifiers for records; print methods for records are not supported either (but reader-name option is supported)
7 sxm has simplified numerical tower: only fixnums and flonums are supported; no extended math procedures are implemented except for bitwise operations on fixnums, add1, sub1, random, sinh, cosh, and tanh.
8 no generic ports, no read-token, no if-exists arguments to i/o procedures, no graph printing (#n= and #n#), no fasl output
9.3 no modules or extended identifier-syntax (sxm uses syntax-case implementation from Chez Scheme v5.9f)
10.1 interrupts cannot be disabled; critical sections and signal handlers are not supported
10.2 sxm does not compile to native code; visit, compile-file and friends are not implemented
10.5 heaps cannot be saved incrementally; all heaps are "level-0"
10.6 statistics, sstats and statistics accessors are missing; in addition, there are no cpu-time and real-time procedures (sxm has only current-time)
10.9 no subset modes
11.1 simplified interface to garbage collector: only argument-less collect is implemented
11.2, 11.3 weak pairs cannot be accessed by regular car and cdr (but you can use %car and %cdr) and are not printed like regular pairs; guardians and object locks are not supported
12 Sxm does not provide any files for compatibility with older (pre-6.0) versions of Chez Scheme.

FILES

/usr/local/bin/sxm executable file
/usr/local/bin/sxi executable file (heap image)

SEE ALSO

R. Kent Dybvig, The Scheme Programming Language, Second Edition, Prentice-Hall (1996).
R. Kent Dybvig, Chez Scheme User's Guide, Cadence Research Systems (1998).
IEEE Computer Society, IEEE Standard for the Scheme Programming Language, IEEE Std 1178-1990 (1991).
Daniel P. Friedman and Matthias Felleisen, The Little Schemer, fourth edition, MIT Press (1996).
Harold Abelson and Gerald J. Sussman with Julie Sussman, Structure and Interpretation of Computer Programs, Second Edition, MIT press (1996).
Richard Kelsey, Will Clinger and Jonathan Rees, eds., "Revised5 Report on the Algorithmic Language Scheme," Higher Order and Symbolic Computation 11, 1, 1999.

BUGS

Send your bug reports and suggestions to Sergei Egorov <esl@acm.org>.

Sergei Egorov (esl@acm.org)