Man Page
S9(1) Scheme 9 from Empty Space S9(1)
NAME
s9 - Scheme Interpreter
USAGE
s9 [-qv] [-d image] [-f program] [-- argument ...]
DESCRIPTION
Scheme 9 from Empty Space is an interpreter for a broad
subset of R4RS Scheme. The s9 command starts the
interpreter.
OPTIONS
-d file
Dump heap image to file and exit.
-f program
Run program and exit (implies -q).
-q
Be quiet: skip banners and prompts, exit on errors.
-v
Display version and exit.
--
Arguments following -- are not interpreted by S9fES.
TECHNICAL DETAILS
S9fES is a tree-walking interpreter using deep binding and
hashed environments. It employs a constant-space mark and
sweep garbage collector with in-situ string and vector pool
compaction. Memory pools grow on demand.
The interpreter uses bignum integer arithmetics exclusively.
It provides both low-level macros (see MACROS below) and
define-syntax/syntax-rules.
ADDITIONS
The symbol ** is always bound to the normal form of the
expression most recently evaluated at the top level.
These S9 procedures are not in R4RS:
(cond-expand (s9fes form ...)) => form ...
S9fES supports a subset of SRFI-0-style cond-expand. It
defines the s9fes and scheme-9-from-empty-space feature
IDs.
(delete-file string) => unspecific
Delete the file specifed in the argument. If the file
does not exist or cannot be deleted, report an error.
(expand-quasiquote form) => expanded-form
If form is a quasiquoted expression, re-write it to an
equivalent expression that does not use quasiquotation.
(expand-macro form) => expanded-form
If form applies a macro, return the expanded form, else
return the form.
(file-exists? string) => boolean
Return #t if the file specifed in the argument exists
and otherwise #f.
(fold-left proc base list ...) => folded-list
Combine the elements of the lists using proc. Combine
elements left-associatively. Base is the leftmost
element.
(fold-right proc base list ...) => folded-list
Combine the elements of the lists using proc. Combine
elements right-associatively. Base is the rightmost
element.
(gensym) => symbol
Return a fresh symbol.
(map-car proc list) => mapped-list
This is equal to map with a single list.
(print form ...) => unspecific
Write multiple forms separated by spaces.
(set-input-port! input-port) => unspecific
Destructively set the current input port.
(set-output-port! output-port) => unspecific
Destructively set the current output port.
(wrong string form) => bottom
Print an error message of the form error: string: form
and terminate program execuation. Form may be omitted.
Redefinition of these procedures is safe except for expand-
quasiquote and wrong.
MACROS
A S9fES macro is a procedure that is applied to its
unevaluated arguments. The macro application is replaced
with the value returned by the procedure. This happens
before the expression containing the macro application is
evaluated, so a macro rewrites its own application:
(define-macro (m x) `(lambda () ,x))
; (m 27) is rewritten as (lambda () 27)
(m 27) => #<procedure ()>
((m 27)) => 27
The define-macro form introduces a new macro:
(define-macro name procedure) => unspecific
(define-macro (name args ...) body) => unspecific
Both of these forms introduce the keyword name and bind it
to a procedure. The first form requires the second argument
to be a procedure. Analogous to define the second form
implies a procedure definition.
Macros may contain applications of macros that were defined
earlier. Macros may not recurse, but they may implement
recursion internally using letrec.
LIMITATIONS
These parts of R4RS are not implemented:
Control: call-with-current-continuation.
I/O: char-ready?.
Transcripts: transcript-off, transcript-on.
Numeric base prefixes: #b, #d, #o, #x.
Numeric tower: rational, float, complex numbers.
Numeric syntax and procedures: #e, #i, /, acos, angle, asin,
atan, ceiling, complex?, cos, denominator, exact->inexact,
exact?, exp, floor, imag-part, inexact->exact, inexact?,
log, magnitude, make-polar, make-rectangular, numerator,
rational, rationalize, real-part, real?, round, sin, tan,
truncate.
BUGS
Quasiquotation of improper lists does not work.
Nested quasiquotation is currently unsupported.
Patterns of syntax-rules may only contain a single ellipsis.
When using define-syntax, you may not redefine the symbols
syntax-match and syntax-expand.
FILES
PREFIX/share/s9fes/s9.scm
The library part of the interpreter (source code).
PREFIX/share/s9fes/s9.image
The library part of the interpreter (heap image).
$HOME/.s9fes/rc
If present, this file is loaded when the interpreter
starts up.
*.scm
Scheme source code.
ENVIRONMENT
S9FES_LIBRARY_PATH
A colon-separated list of directories which will be
searched for the s9 library when the interpreter is
launched.
Default: .:~/.s9fes:/usr/local/share/s9fes
SIGNALS
These work only if POSIX signal handling was enabled at
compile time.
SIGINT
Abort input or terminate program execution.
SIGQUIT
Terminate the interpreter process (emergency exit).
REFERENCES
http://www-swiss.ai.mit.edu/~jaffer/r4rs_toc.html
The Revised^4 Report on the Algorithmic Language Scheme.
http://www.lulu.com/content/1010408
Scheme 9 from Empty Space -- A Guide to Implementing
Scheme in C.
AUTHOR
Nils M Holm <nmh@t3x.org>
S9 Interpreter S9(1)