Re: What's wrong with Common Lisp's lambda ?



Barry Margolin <barmar@xxxxxxxxxxxx> writes:

In article <1159451585.361549.266980@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Karol Skocik" <Karol.Skocik@xxxxxxxxx> wrote:

Hi,
I have just read this article:

http://www.ddj.com/184404384;jsessionid=KLMB3AY1Q0DHQQSNDLPCKH0CJUNN2JVN?_requ
estid=71496

and in the section "Impact of Logic", I saw this :

Scheme, a dialect of Lisp which got lambda right (Guy Steele and Gerald
Sussman, 1975; http://www.schemers .org/).

I am a happy CL lambda user, and can't find something wrong in CL's
lambda...

Could some functional guru explain me what they meant?

Common Lisp adopted some features of Scheme's lambda, so it doesn't have
as many problems as earlier dialects of Lisp. But there are still
holes. Although CL has lexical extent for variable bindings, it only
has dynamic extent for control bindings. So you can't do:

(defun make-bad-closure ()
(tagbody
label
(print 'got-here)
(lambda () (go label))))

(funcall (make-bad-closure))

Your code has a bug in it; tagbody returns nil, not the lambda.
If we fix that, and execute it piecemeal, then it becomes clear why
CL didn't take this particular aspect of Scheme:

CL-USER(1): (defun make-bad-closure ()
(tagbody
label
(print 'got-here)
(return-from make-bad-closure (lambda () (go label)))))
MAKE-BAD-CLOSURE
CL-USER(2): (make-bad-closure)

GOT-HERE
#<Interpreted Closure (:INTERNAL MAKE-BAD-CLOSURE) @ #x4071fe7a>
CL-USER(3): (funcall *)
Error: Cannot go to LABEL, its body has been exited.
[condition type: CONTROL-ERROR]

Restart actions (select using :continue):
0: Return to Top Level (an "abort" restart).
1: Abort entirely from this (lisp) process.
[1] CL-USER(4):

Looks like a CPS issue to me, not a lambda issue (at least directly).

--
Duane Rettig duane@xxxxxxxxx Franz Inc. http://www.franz.com/
555 12th St., Suite 1450 http://www.555citycenter.com/
Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182
.



Relevant Pages

  • Re: quote semantics
    ... with some useful work on Lisp libraries, if you fall that way GTF ... ask for that one, too, whether it was all that related to the Lambda ... And certainly CL took influence from Scheme, ... claim that this community, which is entirely composed of people who, ...
    (comp.lang.lisp)
  • Re: Python syntax in Lisp and Scheme
    ... > not a dialect of Lisp but a separate Lisp-like language. ... Scheme", "Scheme is a statically scoped and properly tail-recursive ... The Scheme community has the SRFI process for developing additional ...
    (comp.lang.lisp)
  • Re: Whats wrong with Common Lisps lambda ?
    ... |> Scheme, a dialect of Lisp which got lambda right (Guy Steele and Gerald ...
    (comp.lang.lisp)
  • Re: Whats wrong with Common Lisps lambda ?
    ... Scheme, a dialect of Lisp which got lambda right (Guy Steele and Gerald ...
    (comp.lang.lisp)
  • Re: Whats wrong with Common Lisps lambda ?
    ... a dialect of Lisp which got lambda right (Guy Steele and Gerald ... Although CL has lexical extent for variable bindings, ...
    (comp.lang.lisp)