Reputation: 254
The first function definition in the 1974 edition of the Little Lisper appears as follows:
(ISLAT (LAMBDA (L)
(COND
((NULL L) T)
((ATOM (CAR L))(ISLAT (CDR L)))
(T F)
) ))
This doesn't look like a proper function definition and it won't run as is in SBCL 1.3.14. It generates two errors: Undefined function: ISLAT Undefined variable: F
In fact T is also undefined, although Friedman uses it like a truth predicate in most of the function examples. As far as I can tell, in this definition, only LAMBDA, COND, NULL, ATOM, CAR, CDR are valid in sbcl.
Is this definition some function specification that is specific to lisps of the 1974 era or did Friedman just leave out (define) or (defunc) from his definitions?
Upvotes: 0
Views: 158
Reputation: 139241
If you look at older Lisp definitions like in Lisp 1.5, they might have source looking something like
DEFINE ((
(ISLAT (LAMBDA (L)
(COND
((NULL L) T)
((ATOM (CAR L))(ISLAT (CDR L)))
(T F))))
))
ISLAT
is the function name. DEFINE
is a pseudo function and allows to define one or more functions.
The Lisp 1.5 manual has this example
DEFINE ((
(MEMBER (LAMBDA (A X) (COND ((NULL X) F)
( (EQ A (CAR X) ) T) (T (MEMBER A (CDR X))) )))
(UNION (LAMBDA (X Y) (COND ((NULL X) Y) ((MEMBER
(CAR X) Y) (UNION (CDR X) Y)) ( T (CONS (CAR X)
(UNION (CDR X) Y))) )))
(INTERSECTION (LAMBDA (X Y) (COND ((NULL X) NIL)
( (MEMBER (CAR X) Y) (CONS (CAR X) (INTERSECTION
(CDR X) Y))) ( T (INTERSECTION (CDR X) Y)) )))
))
where DEFINE
defines three functions MEMBER
, UNION
and INTERSECTION
.
How to deal with that?
If you have source code, you can write a simple frontend such that DEFINE (...)
is parsed and translated.
If you manually translate Lisp 1.5 code to Common Lisp: you have to replace DEFINE
with or or more DEFUN
.
Something like
DEFINE ((
(ISLAT (LAMBDA (L)
(COND
((NULL L) T)
((ATOM (CAR L))(ISLAT (CDR L)))
(T F))))
))
is
(DEFUN ISLAT (L)
(COND
((NULL L) T)
((ATOM (CAR L))(ISLAT (CDR L)))
(T F)))
Upvotes: 3