This document describes the extensions of standard Scheme used in, or related to, the C311 course, but not described in the EOPL text. Transcripts beginning with > illustrate these extensions.
The procedure gensym, provided by Chez Scheme, returns returns a fresh symbol (a newly generated symbol) when called with no arguments. In Chez Scheme, gensyms (symbols returned by gensym) print as #:g followed by a natural number, as indicated in the example above. In EOPL they print as g followed by a natural number.
> (gensym) #:g0
The procedure printf, provided by Chez Scheme, is patterned loosely after the C++ procedure of the same name. It takes a format string followed optionally by other arguments. The characters of the format string are printed in order from left to right until the end of the string is reached, except that if during this process one of the two character sequences that follow is encountered, instead of printing the two characters the specified action is taken.
> (printf "The ~s procedure is very ~a.~%" "printf" "handy") The "printf" procedure is very handy. > (printf "~~dum, ~cdee~%" #\~) ~dum, ~dee
The procedure error, provided by Chez Scheme, takes a symbol, S, followed by a format string and optionally other arguments. It prints a newline, followed by "Error in S: text", where text is the result of invoking printf with the format string and following arguments, followed by another newline, and resets Scheme. When Scheme is reset, control is returned to the waiter (read-evaluate-print loop) and a new top-level prompt is printed.
> (begin (display 'before) (error 'testing "one, ~s" 'two) (display after)) before Error in testing: one, two >
Observe that after was never displayed.
By convension the symbol passed as the first argument to error names the procedure that calls it. EOPL uses a version of the procedure error that is somewhat different..
A new datatype facility, using the forms define-datatype and type-case, used in class and assignments as of Fall 1998, replaces the EOPL record mechanism based on define-record and variant-case.
To use this facility