From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: apatheticagnostic Newsgroups: gmane.emacs.help Subject: Re: elisp - anonymous function in an association list? Date: Thu, 29 Nov 2007 07:01:53 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <10f246a9-2a9b-477e-806d-7e3b38ce2607@i29g2000prf.googlegroups.com> <5r81u5F131t6qU1@mid.individual.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196350925 26161 80.91.229.12 (29 Nov 2007 15:42:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Nov 2007 15:42:05 +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 16:42:12 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 1IxlWi-0002Hd-4y for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 16:42:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IxlWS-0005Kb-UC for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 10:41:52 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!a35g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Original-NNTP-Posting-Host: 76.251.226.7 Original-X-Trace: posting.google.com 1196348513 24423 127.0.0.1 (29 Nov 2007 15:01:53 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 29 Nov 2007 15:01:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a35g2000prf.googlegroups.com; posting-host=76.251.226.7; posting-account=NwyZJgoAAACP04-gqkVuGlZqnbHiXJ8v User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.10) Gecko/20071126 Ubuntu/7.10 (gutsy) Firefox/2.0.0.10, gzip(gfe), gzip(gfe) Content-Disposition: inline Original-Xref: shelby.stanford.edu gnu.emacs.help:154257 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:49685 Archived-At: 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!"))))) > > (defun test-call (x) > (funcall (eval (car (cdr (assoc x sample-alist)))))) > > (test-call "a") > "We worked!" > > (test-call "b") > "B worked too!" > > regards > > Marc 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. Thanks a lot!