Next: , Previous: , Up: Scheme Syntax Extension Packages   [Contents][Index]

3.6 Syntax-Case Macros

(require 'syntax-case)

Function: macro:expand expression
Function: syncase:expand expression

Returns scheme code with the macros and derived expression types of expression expanded to primitive expression types.

Function: macro:eval expression
Function: syncase:eval expression

macro:eval returns the value of expression in the current top level environment. expression can contain macro definitions. Side effects of expression will affect the top level environment.

Procedure: macro:load filename
Procedure: syncase:load filename

filename should be a string. If filename names an existing file, the macro:load procedure reads Scheme source code expressions and definitions from the file and evaluates them sequentially. These source code expressions and definitions may contain macro definitions. The macro:load procedure does not affect the values returned by current-input-port, current-error-port, and current-output-port.

This is version 2.1 of syntax-case, the low-level macro facility proposed and implemented by Robert Hieb and R. Kent Dybvig.

This version is further adapted by Harald Hanche-Olsen <hanche @ imf.unit.no> to make it compatible with, and easily usable with, SLIB. Mainly, these adaptations consisted of:

If you wish, you can see exactly what changes were done by reading the shell script in the file syncase.sh.

The two PostScript files were omitted in order to not burden the SLIB distribution with them. If you do intend to use syntax-case, however, you should get these files and print them out on a PostScript printer. They are available with the original syntax-case distribution by anonymous FTP in cs.indiana.edu:/pub/scheme/syntax-case.

In order to use syntax-case from an interactive top level, execute:

(require 'syntax-case)
(require 'repl)
(repl:top-level macro:eval)

See the section Repl (see Repl) for more information.

To check operation of syntax-case get cs.indiana.edu:/pub/scheme/syntax-case, and type

(require 'syntax-case)
(syncase:sanity-check)

Beware that syntax-case takes a long time to load – about 20s on a SPARCstation SLC (with SCM) and about 90s on a Macintosh SE/30 (with Gambit).

3.6.1 Notes

All R4RS syntactic forms are defined, including delay. Along with delay are simple definitions for make-promise (into which delay expressions expand) and force.

syntax-rules and with-syntax (described in TR356) are defined.

syntax-case is actually defined as a macro that expands into calls to the procedure syntax-dispatch and the core form syntax-lambda; do not redefine these names.

Several other top-level bindings not documented in TR356 are created:

The syntax of define has been extended to allow (define id), which assigns id to some unspecified value.

We have attempted to maintain R4RS compatibility where possible. The incompatibilities should be confined to hooks.ss. Please let us know if there is some incompatibility that is not flagged as such.

Send bug reports, comments, suggestions, and questions to Kent Dybvig (dyb @ iuvax.cs.indiana.edu).


Next: , Previous: , Up: Scheme Syntax Extension Packages   [Contents][Index]