Portable syntax-case

R. Kent Dybvig Oscar Waddell

The syntax-case macro system implements the restricted high-level syntax-rules macros of the Revised5 Report as well as the equally high-level but general-purpose syntax-case macros. It also supports a compatible module system that allows import and export of macro bindings as well as bindings for variables and modules.

The system is documented in Section 3.1 and Chapter 8 of The Scheme Programming Language, third edition [1] and in Chapter 9 of the Chez Scheme User's Guide [2]. The former has more introductory material and examples, while the latter documents some aspects of the system not covered by the former.

Aspects of the system and its implementation are described in Syntactic abstraction in Scheme [3] and Extending the Scope of Syntactic Abstraction [4]. Additional examples of its use are given in Writing hygienic macros in Scheme with syntax-case [5].

The portable system is designed to be adaptable with minimal effort to any Revised5 Report implementation of Scheme, with the provision of a small set of implementation-dependent hooks to install the expander. Included with the portable expander are definitions of each of the syntactic forms supported by the Revised5 Report. Along with a reader, the system forms a complete front-end for Scheme. If the reader and evaluator support source annotations (e.g., file and line number information), these are handled as well to provide source-object correlation.

The portable syntax-case implementation consists of one file, psyntax.ss. The file psyntax.pp is an expanded version of the file that may be used for bootstrapping the system. See the porting notes in psyntax.ss

Please let us know if you successfully port this code to a new Scheme implementation, and also please allow us to include the hooks you develop in doing the port in this directory for use by others.

Please also contact us if you have difficulty porting to a new Scheme implementation or if you discover that the implementation depends on nonportable features of Chez Scheme in some undocumented way.

Release Notes

Version numbers refer to the version of Chez Scheme from which the portable version was extracted.

Version 7.3 (2/26/2007)

[psyntax.ss, psyntax.pp]

Version 7.1 (8/1/2006)

[psyntax.ss, psyntax.pp]

Version 7.0 (9/2/2005)

[psyntax.ss, psyntax.pp]

Version 6.9c (9/2/2004)

[psyntax.ss, psyntax.pp]

Version 6.9a (5/13/2003)

[psyntax.ss, psyntax.pp]

Version 6.9 (7/12/2002)

[psyntax.ss, psyntax.pp]

Version 6.8 (2/6/2002)

[psyntax.ss, psyntax.pp]

Version 6.3 (8/30/2000)

[psyntax.ss, psyntax.pp]

References

[1] R. Kent Dybvig. The Scheme Programming Language, third edition. MIT Press, 2003. Introduction and reference manual for ANSI Standard Scheme with numerous short and extended examples and exercises. [full textbibtex]

[2] R. Kent Dybvig. Chez Scheme User's Guide. Cadence Research Systems, 1998. User's guide and reference manual for Chez Scheme. Complements [1]. [full textbibtex]

[3] R. Kent Dybvig, Robert Hieb, and Carl Bruggeman. Syntactic abstraction in Scheme. Lisp and Symbolic Computation, 5(4):295-326, 1993. Describes the syntax-case macro system and its implementation and argues why it is superior to previous attempts at hygienic macro systems. [full textabstractbibtex]

[4] Oscar Waddell and R. Kent Dybvig. Extending the scope of syntactic abstraction. In Conference Record of the Twenty Sixth Annual ACM Symposium on Principles of Programming Languages, 203-213, January 1999. Describes the Chez Scheme module system and its interaction with the syntax-case expander. [full textabstractbibtex]

[5] R. Kent Dybvig. Writing hygienic macros in Scheme with syntax-case. Technical Report 356, Indiana Computer Science Department, June 1992. Introduces the syntax-case macro system through a series of examples. Some overlap with [3]. [full textabstractbibtex]

[6] R. Kent Dybvig. The Scheme Programming Language, second edition. Prentice Hall, 1996. Second edition of [1]. [full textbibtex]