The Essentials of Programming Languages language in DrScheme provides all of the functions of R5RS (see r5rs), plus the forms and procedures described below. It is intended for use with the textbook [EoPL].
Differences from the book:
Datatypes must be defined before they are used in cases expressions. This constraint enables better and earlier error reporting.
Some examples in the book’s code (or at least the code distributed for the book) must be changed by moving datatype definitions earlier.
The sllgen: functions have been changed to syntactic forms. This change is also related to better error reporting.
All examples in the book work with the sllgen: forms.
Defines the datatype id and a function predicate-id that returns #t for instances of the datatype, and #f for any other value.
Each variant-id is defined as a constructor function that creates an instance of the datatype; the constructor takes as many arguments as the variant’s field-ids, and each argument is checked by applying the function produced by the variant’s predicate-expr.
In DrScheme v209 and older, when constructor-based printing was used, variant instances were printed with a make- prefix before the variant name. Thus, for compatibility, in addition to variant-id, make-variant-id is also defined for each variant-id (to the same constructor as variant-id).
Branches on the datatype instance produced by expr, which must be an instance of the specified datatype-id (previously defined with define-datatype).
Defined in the textbook’s Appendix A [EoPL]. However, the DrScheme versions are syntactic forms, instead of procedures, and the arguments must be either quoted literal tables or identifiers that are defined (at the top level) to quoted literal tables.
Defined in the EoPL textbook’s Appendix A [EoPL] (and still a function).
As in the book.
As in the book [EoPL].
empty : empty?
The empty list.
Evaluates expr, and prints timing information before returning the result.
(collect-garbage) → void?
Performs a garbage collection (useful for repeatable timings).
For debugging: trace redefines each id at the top level (bound to a procedure) so that it prints arguments on entry and results on exit. The untrace form reverses the action of trace for the given ids.
Tracing a function causes tail-calls in the original function to become non-tail calls.
(provide provide-spec )
Defined only in the top-level namespace (i.e., not in a module); mutate this variable to install an exception-handling thunk. Typically, the handler thunk escapes through a continuation.
The eopl/eopl library sets this variable to #f in the current namespace when it executes.
(install-eopl-exception-handler) → void?
Sets an exception handler to one that checks eopl:error-stop.
The eopl/eopl library calls this function when it executes.
“Essentials of Programming Languages, Second Edition,” MIT Press, 2001.