define-datatype
cases
sllgen: make-string-scanner
sllgen: make-string-parser
sllgen: make-stream-parser
sllgen: make-define-datatypes
sllgen: show-define-datatypes
sllgen: list-define-datatypes
sllgen: make-rep-loop
eopl: error
eopl: printf
eopl: pretty-print
list-of
always?
empty
time
collect-garbage
trace
untrace
provide
eopl: error-stop
install-eopl-exception-handler
Bibliography
Version: 4.0.2

 

Essentials of Programming Languages Language

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:

 (require eopl/eopl)

(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 (previously defined with define-datatype).

sllgen:make-string-scanner

sllgen:make-string-parser

sllgen:make-stream-parser

sllgen:make-define-datatypes

sllgen:show-define-datatypes

sllgen:list-define-datatypes

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.

sllgen:make-rep-loop : procedure?

Defined in the EoPL textbook’s Appendix A [EoPL] (and still a function).

eopl:error : procedure?

As in the book.

(eopl:printf form v ...)  void?

  form : string?

  v : any/c

(eopl:pretty-print v [port])  void?

  v : any/c

  port : output-port? = (current-output-port)

Same as PLT Scheme’s printf and pretty-print.

((list-of pred ...+) x)  boolean?

  pred : (any/c . -> . any)

  x : any/c

(always? x)  boolean?

  x : any/c

As in the book [EoPL].

empty : empty?

The empty list.

(time expr)

Evaluates expr, and prints timing information before returning the result.

(collect-garbage)  void?

Performs a garbage collection (useful for repeatable timings).

(trace id ...)

(untrace id ...)

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 ...)

Useful only with a module that uses eopl/eopl as a language: exports identifiers from the module. See provide from mzscheme for more information.

eopl:error-stop : (-> any/c)

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.

Bibliography

[EoPL]

 

Essentials of Programming Languages, Second Edition,” MIT Press, 2001.