From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: elisp - anonymous function in an association list? Date: Thu, 29 Nov 2007 16:24:57 -0500 Message-ID: References: <10f246a9-2a9b-477e-806d-7e3b38ce2607@i29g2000prf.googlegroups.com> <5r81u5F131t6qU1@mid.individual.net> <85k5o13w4q.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1196372587 11891 80.91.229.12 (29 Nov 2007 21:43:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Nov 2007 21:43:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 29 22:43:14 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 1IxrA5-0008UG-Mg for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 22:43:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ixr9p-0002p8-SV for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 16:42:53 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Thu, 29 Nov 2007 15:25:00 -0600 Original-Newsgroups: gnu.emacs.help User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X) Original-Lines: 46 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 24.34.108.171 Original-X-Trace: sv3-lp0chBskLYLIoiaDs1QdUwjP7PUvCq+Sk2Ekcn7VXguBqXcDCx6LAbA/BbBwNzszbibDEtE6RW0RpIP!peT+7GMOXenP2eJOfPDFRVmW4xKU4qvfV2OeYPw8W05P55lT0giXEFA8O+uwx/XINbcOetuBPCG6!PZz16uNultsOe9Uw6C9YAA== Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.36 Original-Xref: shelby.stanford.edu gnu.emacs.help:154273 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:49700 Archived-At: In article <85k5o13w4q.fsf@lola.goethe.zz>, David Kastrup wrote: > apatheticagnostic writes: > > > On Nov 29, 9:50 am, Marc Tfardy wrote: > >> apatheticagnostic schrieb: > >> > >> > take, for example this code showing what I mean: > >> > >> > (defvar sample-alist '(("a" '(lambda () > >> > (message "We worked!"))) > >> > ("b" #'(lambda () > >> > (message "B worked too!"))))) > >> > >> > (defun test-call (x) > >> > (funcall (cdr (assoc x sample-alist)))) > >> > >> > (test-call "a") > >> > (test-call "b") > >> > >> > Both calls fail, with an error message like so: > >> > >> This seems to work: > >> > >> (defvar sample-alist '(("a" (lambda () (message "We worked!"))) > >> ("b" (lambda () (message "B worked too!"))))) > > [fixed to omit the utterly pointless eval:] > > >> (defun test-call (x) > >> (funcall (car (cdr (assoc x sample-alist))))) > > > So it does. Well, I feel dumb now. I assumed that I would need to > > quote the lambda expressions in some way to prevent them from being > > evaluated at definition. > > lambda is self-quoting. It is preferable not to quote it nevertheless, > because then the byte compiler can compile and optimize it. The self-quoting of lambda is not the issue here. He already quoted the list -- the problem was that he embedded another quote within the list. This simply quoted the quote. -- Barry Margolin Arlington, MA