Advanced Scheme: Some Naughty Bits
In 2003 and 2004, I ran two-night seminars, under the aegis of the MIT SIPB , introducing features of
Scheme that aren't usually covered in undergraduate classes such as
MIT's 6.001. The first night covered hygienic macros , and
the second continuations. Hygienic macros are an elegant
mechanism for developing new syntax. Continuations are a powerful
control-flow construct from which nearly any other control-flow
structure, including exceptions, co-routines, threads, and
backtracking may be derived.
Macros are introduced in the first set of slides, followed by
continuations in the second. Both are used in the second set to
implement a variety of control-flow constructs on top of scheme,
culminating with implementations of cooperative multi-threading, and
nondeterministic Prolog-esque programming mechanisms.
These slides are slightly error-corrected from their presentation in the classes; please let me know if you find more errors.
Corresponding source code (from '03):
- Macro slides presented January 7,2003. These slides were a fairly tightly-focused tutorial on the official R5RS hygienic macro system.
- Macro slides presented January 12,2004. I tried a different approach this year, presenting Common Lisp-style defmacro and syntactic closures ("Syntactic Closures", by Alan Bawden and Jonathan Rees) in addition to official R5RS hygienic macros. I think it's a more interesting talk this way.
- Continuation slides presented January 8,2003. The cooperative threading implementation at the end is particularly lame, but hopefully conveys the idea well enough.
- Continuation slides presented January 14,2004. These are only mildly tweaked from '03; the threading example is as lame as ever.
General Scheme Resources
R5RS Hygienic Macros
Non-deterministic programming in Scheme
Jeremy H. Brown < email@example.com >