Version: 5.1.1
Essentials of Programming Languages Language
The Essentials of Programming Languages language in DrRacket
provides a subset of functions and syntactic forms of
mzscheme—mostly the ones that correspond to
r5rs forms. See below for a complete list. The
language is intended for use with the textbook [EoPL].
The following bindings are re-provided from
mzscheme:
| (define-datatype id predicate-id | | (variant-id (field-id predicate-expr) ...) | | ...) |
|
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).
| (cases datatype-id expr | | (variant-id (field-id ...) result-expr ...) | | ...) |
|
| (cases datatype-id expr | | (variant-id (field-id ...) result-expr ...) | | ... | | (else result-expr ...)) |
|
Branches on the datatype instance produced by
expr, which
must be an instance of the specified
datatype-id that is
defined with
define-datatype.
Defined in the textbook’s Appendix B [
EoPL]. However, the
DrRacket 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 B [
EoPL]
(and still a function).
As in the book.
The empty list.
Evaluates expr, and prints timing information before returning the
result.
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.
Useful only with a module that uses
eopl/eopl as a
language: exports identifiers from the module. See
provide
from
mzscheme for more information.
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.
Sets an exception handler to one that checks
eopl:error-stop.
The eopl/eopl library calls this function when it
executes.
Bibliography