From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Costanza Newsgroups: gmane.emacs.help Subject: Re: Nested Lambda function gives error in common lisp, guile, emacs lisp but works in scheme. Why? Date: Sun, 07 Oct 2007 13:02:10 +0200 Message-ID: <5mrsliFesppjU1@mid.individual.net> References: <1191735269.656673.146370@50g2000hsm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1191782060 4199 80.91.229.12 (7 Oct 2007 18:34:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2007 18:34:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 07 20:34:17 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IeaxE-0000YN-36 for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2007 20:34:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ieax8-000770-Sm for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2007 14:34:10 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: comp.lang.lisp,gnu.emacs.help,comp.lang.scheme Original-Lines: 39 Original-X-Trace: individual.net Arf3r9l4QZvFNcVZ0Is+Hg2zZJ36PEFP5pBbVnXdnt4WZ/xOQT Cancel-Lock: sha1:hYFdpa17oITrwON0twZMQAxXNUQ= User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) In-Reply-To: <1191735269.656673.146370@50g2000hsm.googlegroups.com> Original-Xref: shelby.stanford.edu comp.lang.lisp:230531 gnu.emacs.help:152677 comp.lang.scheme:74316 X-Mailman-Approved-At: Sun, 07 Oct 2007 14:32:24 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:48191 Archived-At: gnuist006@hotmail.com wrote: > Please explain the below errors: > [1]> (((lambda (a) (lambda (b) (list a b))) 1) 2) > > *** - EVAL: ((LAMBDA (A) (LAMBDA (B) (LIST A B))) 1) is not a function > name; try using a symbol > instead > The following restarts are available: > USE-VALUE :R1 You may input a value to be used instead. > ABORT :R2 ABORT > > > Similar errors in emacs lisp. Common Lisp (and presumably Emacs Lisp) is a Lisp-2, which means that function positions are evaluated differently than value positions. In 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. Your code works in Common Lisp when you do this: (funcall (funcall (lambda (a) (lambda (b) (list a b))) 1) 2) This looks inconvenient, but there are good reasons why one might prefer a Lisp-2 over a Lisp-1 (like Scheme). See http://www.dreamsongs.com/Separation.html If you google for Lisp-2 and Lisp-1, you will find more information. There have been a number of discussions about this in comp.lang.lisp. 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/