If you have corrections that are not listed already, I would appreciate email. In the interest of time, many of these comments and corrections are copied directly from messages I have received.- JCM
find
would have been written
thus:
DEFINE (( (FIND (LAMBDA (X Y) (COND ((EQ Y NIL) NIL) ((EQ X (CAR Y)) X) (T (FIND X (CDR Y)))))) ))(Actually, it would probably have been written so as to make it possible to distinguish a successful search from an unsuccessful one even when
X
is NIL
, but that's a design flaw in Mitchell's code rather than
a syntax difference.)
rplaca
and rplacd
are messed up: Lisp rplaca
corresponds to Scheme set-car!
and Lisp rplacd
to Scheme set-cdr!
. Also, there is
no reason to capitalize `setq
'. Early implementations of Lisp
for environments that supported lower-case letters were mostly
case-insensitive.
(plus (square x) y)
' should be `(+ (square x) y)
'.
x
and symbols like 'A
. The passage should read something like
this:
Suppose we call this list
x
and we want to change the third element of listx
to'E
. In pure Lisp, we cannot change any of the cells of this list, but we can define a new list with elements'A
,'B
,'E
,'D
. The following expression constructs this new list; `(cadr x)
' means ``car of the cdr ofx
'' and `(cdddr x)
' means ``cdr of the cdr of the cdr ofx
''.
(cons (car x) (cons (cadr x) (cons 'E (cdddr x))))
Note that evaluating this expression involves creating new cons cells for the first three elements of the list and, if there is no further use for them, eventually garbage-collecting the old cells used for the first three elements of
x
. In contrast, in impure Lisp, we can change the third cell directly by using the expression
(rplaca (cddr x) 'E)
If all we need is the list we obtained by replacing the third element of
x
with'E
, then this expression gets the result we want far more efficiently.
if =
x=0
' should be `if x = 0
'
k
is erroneous and should be deleted.~1
, ~2
, and so on. The minus sign is used
only for the subtraction operation.
compose
should be printed in
the font used for ML code.
make_counter
in the ML version is renamed mk_counter
in the C version.
Figure 7.10 uses both of these names, as well as the contracted form make_c
.power(a,
a, c)
' should be a question mark.
x
' and `10
'.
X
, but the accompanying
code uses the variable x
instead. Since ML is case-sensitive,
it makes a difference; all the occurrences of `x
' (in the code,
and in the line just below the code display) should be changed to `X
'.t1
'
should be `tl
' (that is, tee-one should be tee-ell).
OPENor
'
should be `OPEN or
'.mvar
datatype at the bottom of the
page, there should be a comma after `putCh: 'a chan
'.Here is the outline of a simple program (devised by William Pugh in ``The Java memory model is fatally flawed,'' Concurrency: practice and experience 12 [2000], 445-455) whose behavior is affected by the relaxed prescient store rule.
g := false
' should be `go := false
'.
Mycamera
' should be `MyCamera
'.
This was eventually achieved by Robert Kowalski (``Predicate logic as a programming language,'' in Proceedings of IFIP Congress 74, North-Holland, 1974).
y
2' should be `y
'.
A
'
and `B
' are wrong throughout the paragraph.However, no checks at compilation time enforce the conventions of this style. Design errors will be discovered at run time or not at all.
Ex. 5.3a has a simple answer that is probably not what you intend: ...
Ex 7.10b seems to be asking for an affirmative answer, by contrast with 7.10c. But if so, ...
Thanks to the many readers who contributed corrections, including Hans J. Schneider, John David Stone, Jonathan Wellons, and students and teaching assistants of Stanford CS 242.
Return to J Mitchell home page