eopl doc updates

svn: r10834
This commit is contained in:
Matthew Flatt 2008-07-18 19:00:38 +00:00
parent 867306caff
commit 7c6b93f531
2 changed files with 107 additions and 37 deletions

View File

@ -1,5 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual @(require scribble/manual
scribble/struct
scheme/list
(for-label eopl/eopl (for-label eopl/eopl
scheme/contract scheme/contract
(only-in scheme printf pretty-print))) (only-in scheme printf pretty-print)))
@ -10,33 +12,101 @@
(define id (scheme provide)))) (define id (scheme provide))))
@(def-mz mzscheme-provide) @(def-mz mzscheme-provide)
@(define-syntax-rule (reprovide id ...)
(*threecolumns (list (scheme id) ... 'nbsp 'nbsp)))
@(define (*threecolumns l)
(let* ([len (length l)]
[third (quotient len 3)]
[a (take l third)]
[b (take (list-tail l third) third)]
[c (list-tail l (* 2 third))]
[spacer (hspace 2)]
[to-flow (compose make-flow list make-paragraph list)])
(make-table #f
(map (lambda (a b c)
(list (to-flow spacer)
(to-flow a)
(to-flow spacer)
(to-flow b)
(to-flow spacer)
(to-flow c)))
a b c))))
@title{@italic{Essentials of Programming Languages} Language} @title{@italic{Essentials of Programming Languages} Language}
The @italic{Essentials of Programming Languages} language in DrScheme The @italic{Essentials of Programming Languages} language in DrScheme
provides all of the functions of R5RS (see @schememodname[r5rs]), plus provides a subset of functions and syntactic forms of
the forms and procedures described below. It is intended for use with @schememodname[mzscheme]---mostly the ones that correspond to
the textbook @cite["EoPL"]. @scheme[r5rs] forms. See below for a complete list. The
language is intended for use with the textbook @cite["EoPL"].
Differences from the book:
@itemize{
@item{Datatypes must be defined before they are used in
@scheme[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.}
@item{The @scheme[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 @scheme[sllgen:] forms.}
}
@defmodule[eopl/eopl] @defmodule[eopl/eopl]
The following bindings are re-@scheme[provide]d from
@schememodname[mzscheme]:
@reprovide[
make-parameter
parameterize
print-struct
unquote unquote-splicing
quote quasiquote if
lambda letrec define-syntax delay let let* let-syntax letrec-syntax
and or cond case do
begin set!
#%module-begin
#%app #%datum #%top #%top-interaction
#%require #%provide #%expression
syntax-rules ...
cons car cdr pair? map for-each
caar cadr cdar cddr
caaar caadr cadar caddr cdaar cdadr cddar cdddr
caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
= < > <= >= max min + - * /
abs gcd lcm exp log sin cos tan not eq?
make-string
symbol->string string->symbol make-rectangular
exact->inexact inexact->exact number->string string->number
rationalize output-port? current-input-port current-output-port current-error-port
open-input-file open-output-file close-input-port close-output-port
with-output-to-file transcript-on transcript-off flush-output
string-length string-ci<=? string-ci>=? string-append
string-fill!
string->list list->string
vector-length vector-fill!
vector->list list->vector
char-alphabetic? char-numeric? char-whitespace?
char-upper-case? char-lower-case? char->integer integer->char char-downcase
call-with-output-file call-with-input-file with-input-from-file
apply symbol?
null?
list? list length append reverse list-tail
list-ref memq memv member assq assv assoc
procedure?
number? complex? real? rational? integer? exact? inexact? zero?
positive? negative? odd? even?
quotient remainder modulo floor ceiling truncate round
numerator denominator asin acos atan sqrt
expt make-polar real-part imag-part angle magnitude input-port?
read read-char peek-char eof-object?
char-ready?
write display
newline write-char load
string? string string-ref string-set! string=? substring string-copy
string-ci=? string<? string>? string<=? string>=? string-ci<? string-ci>?
vector? make-vector vector vector-ref vector-set!
char? char=? char<? char>? char<=? char>=?
char-ci=? char-ci<? char-ci>? char-ci<=? char-ci>=?
char-upcase boolean? eqv? equal?
force
call-with-values values dynamic-wind
eval]
@defform[(define-datatype id predicate-id @defform[(define-datatype id predicate-id
(variant-id (field-id predicate-expr) ...) (variant-id (field-id predicate-expr) ...)
...)]{ ...)]{
@ -68,8 +138,8 @@ Differences from the book:
(else result-expr ...))]]{ (else result-expr ...))]]{
Branches on the datatype instance produced by @scheme[expr], which Branches on the datatype instance produced by @scheme[expr], which
must be an instance of the specified @scheme[datatype-id] must be an instance of the specified @scheme[datatype-id] that is
(previously defined with @scheme[define-datatype]).} defined with @scheme[define-datatype].}
@deftogether[( @deftogether[(
@defidform[sllgen:make-string-scanner] @defidform[sllgen:make-string-scanner]
@ -79,14 +149,14 @@ Differences from the book:
@defidform[sllgen:show-define-datatypes] @defidform[sllgen:show-define-datatypes]
@defidform[sllgen:list-define-datatypes])]{ @defidform[sllgen:list-define-datatypes])]{
Defined in the textbook's Appendix A @cite["EoPL"]. However, the Defined in the textbook's Appendix B @cite["EoPL"]. However, the
DrScheme versions are syntactic forms, instead of procedures, and DrScheme versions are syntactic forms, instead of procedures, and
the arguments must be either quoted literal tables or identifiers the arguments must be either quoted literal tables or identifiers
that are defined (at the top level) to quoted literal tables.} that are defined (at the top level) to quoted literal tables.}
@defthing[sllgen:make-rep-loop procedure?]{ @defthing[sllgen:make-rep-loop procedure?]{
Defined in the @italic{EoPL} textbook's Appendix A @cite["EoPL"] Defined in the @italic{EoPL} textbook's Appendix B @cite["EoPL"]
(and still a function).} (and still a function).}
@defthing[eopl:error procedure?]{ @defthing[eopl:error procedure?]{
@ -97,11 +167,12 @@ Differences from the book:
@defproc[(eopl:printf (form string?) (v any/c) ...) void?] @defproc[(eopl:printf (form string?) (v any/c) ...) void?]
@defproc[(eopl:pretty-print (v any/c) (port output-port? (current-output-port))) void?])]{ @defproc[(eopl:pretty-print (v any/c) (port output-port? (current-output-port))) void?])]{
Same as PLT Scheme's @scheme[printf] and @scheme[pretty-print].} Same as @schememodname[scheme/base]'s @scheme[printf] and @scheme[pretty-print].}
@deftogether[( @deftogether[(
@defproc[((list-of (pred (any/c . -> . any)) ...+) (x any/c)) boolean?] @defproc[((list-of (pred (any/c . -> . any)) ...+) (x any/c)) boolean?]
@defproc[(always? (x any/c)) boolean?])]{ @defproc[(always? (x any/c)) boolean?]
@defproc[(maybe (pred (any/c . -> . boolean?))) boolean?])]{
As in the book @cite["EoPL"].} As in the book @cite["EoPL"].}
@ -153,12 +224,12 @@ Differences from the book:
The @schememodname[eopl/eopl] library calls this function when it The @schememodname[eopl/eopl] library calls this function when it
executes.} executes.}
@(bibliography @(bibliography
(bib-entry #:key "EoPL" (bib-entry #:key "EoPL"
#:title @elem{@italic{Essentials of Programming Languages}, Second Edition} #:title @elem{@italic{Essentials of Programming Languages}, Third Edition}
#:location "MIT Press" #:location "MIT Press"
#:date "2001") #:date "2008"
#:url "http://www.eopl3.com/")
) )

View File

@ -122,17 +122,17 @@
(and (pair? obj) (and (pair? obj)
((car preds) (car obj)) ((car preds) (car obj))
(loop (cdr obj) (cdr preds)))))))))) (loop (cdr obj) (cdr preds))))))))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define empty null)
(define maybe (define maybe
(lambda (pred) (lambda (pred)
(lambda (obj) (lambda (obj)
(or (pred obj) (or (pred obj)
(eqv? obj #f))))) (eqv? obj #f)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define empty null)
(provide time ;; useful to compare implementations (provide time ;; useful to compare implementations
collect-garbage ;; useful with `time' collect-garbage ;; useful with `time'
empty ;; for constructor-based printing empty ;; for constructor-based printing
@ -141,8 +141,7 @@
provide ;; in case someone wants to use a module provide ;; in case someone wants to use a module
make-parameter make-parameter
parameterize parameterize
print-struct print-struct)
maybe)
(provide unquote unquote-splicing (provide unquote unquote-splicing
quote quasiquote if quote quasiquote if