|
From: | Pascal Costanza |
Subject: | Re: Nested Lambda function gives error in common lisp, guile, emacs lisp but works in scheme. Why? |
Date: | Mon, 08 Oct 2007 08:39:16 +0200 |
User-agent: | Thunderbird 2.0.0.6 (Macintosh/20070728) |
David Rush wrote:
On Oct 7, 12:02 pm, Pascal Costanza <p...@p-cos.net> wrote:Common Lisp (and presumably Emacs Lisp) is a Lisp-2, which means that function positions are evaluated differently than value positions.Now I may be demonstrating a certain amount of historical ignorance here, but I was under the impression that Lisp-2 referred to the fact that there were effectively to different *name* spaces, one in which 'ordinary' values were bound and one in which 'callable' values werebound.
This is correct. However, the namespace for ordinary values may also contain callable values, whereas the namespace for callable values may contain callable values only.
However, this text:order to treat a first-class value as a function, you have to shift it via FUNCALL. In order to yield a function as a first-class value, you have look it up with FUNCTION.Makes it sound like there are two fundamentally different *types* of values And FUNCALL and FUNCTION are the type cast operators between those types. Is this a valid way of looking at this?
No, and I am sorry if I have given that impression.Still, the function namespace may contain only callable values, and in that regard that namespace is indeed typed. This is why this may be confusing.
But it is in fact much simpler: (let ((foo 42)) (flet ((foo (x) (print x))) (foo foo)))This code binds 42 to foo in the value namespace, and a function to foo in the function namespace. The first position in the expression (foo foo) looks up the latter, the second position looks up the former. Overall, the whole expression prints 42.
This is all there is to this: The first position is looked up in a different namespace than all the other positions.
Pascal -- My website: http://p-cos.net Common Lisp Document Repository: http://cdr.eurolisp.org Closer to MOP & ContextL: http://common-lisp.net/project/closer/
[Prev in Thread] | Current Thread | [Next in Thread] |