spec 3.1.2.1.2 and the lambda exception
From: Ross Lippert (lippert_at_MATHSTATION031.MIT.EDU)
Date: 08/23/04
- Next message: Tayssir John Gabbour: "Re: E. W. Dijkstra VS. John McCarthy. A rebuttal to Paul Graham's web writings."
- Previous message: Coby Beck: "Re: Lisp readability"
- Next in thread: Matthew Danish: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Matthew Danish: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Rainer Joswig: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Pascal Bourguignon: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Kaz Kylheku: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Barry Margolin: "Re: spec 3.1.2.1.2 and the lambda exception"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Aug 2004 14:57:42 -0400
I have been trying to learn some lisp. I have had some experience in
scheme, which is probably why I even got disturbed by that which is
the source of my question.
Playing around with the age old bank-account example I did something
equivalent to
(defun make-adder (x) (lambda (y) (+ x y)))
((make-adder 1) 1)
and of course, I got an error. What I mean to do here is done by
using funcall. This is part of that 1-namespace vs 2-namespace
issue, which divides scheme and lisp, I know.
However, I can do
((lambda (y) (+ 1 y)) 1)
without having to use funcall, though doing
(funcall (lambda (y) (+ 1 y)) 1)
works too.
The reason seems to come down to a place in the CL spec called
3.1.2.1.2 which says that the car of the s-exp to be interpreted must
be a special form, a macro, a symbol or a lambda expression.
http://www.lispworks.com/reference/HyperSpec/Body/03_abab.htm
When evaluated, these two things look nearly the same:
[2]> (lambda (y) (+ 1 y))
#<CLOSURE :LAMBDA (Y) (+ 1 Y)>
[3]> (make-adder 1)
#<CLOSURE :LAMBDA (Y) (+ X Y)>
Yet, upon substitution into an s-exp, they can do different things.
Of course, this tells me that evaluation in the car position is not
the same as evaluation of the arguments, which is to be expected
from the wording of 3.1.2.1.2. Still it is disconcerting.
I guess that 3.1.2.1.2 allows lambdas and no other expressions
because either:
1) there is some good reason to allow lambda expressions in the car.
2) there is some good reason to disallow arbitrary function-returning
expressions in the car.
Which is it and why?
I read some of the past articles on this group about 3.1.2.1.2 and
did not see this issue discussed.
Thank you,
-r
-- Ross A. Lippert M.I.T., Department of Mathematics Building 2, Room 335 Voice (617) 253-7905 77 Massachusetts Avenue FAX (617) 253-4358 Cambridge, MA 02139-4307 e-mail: lippert@math.mit.edu
- Next message: Tayssir John Gabbour: "Re: E. W. Dijkstra VS. John McCarthy. A rebuttal to Paul Graham's web writings."
- Previous message: Coby Beck: "Re: Lisp readability"
- Next in thread: Matthew Danish: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Matthew Danish: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Rainer Joswig: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Pascal Bourguignon: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Kaz Kylheku: "Re: spec 3.1.2.1.2 and the lambda exception"
- Reply: Barry Margolin: "Re: spec 3.1.2.1.2 and the lambda exception"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]