From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.devel Subject: Re: Macro expansion: Why doesn't the invoked macro see (let (variables))from the invoking one? Date: Thu, 9 Feb 2012 21:23:55 -0800 Message-ID: References: <20120208172638.GB3523@acm.acm> <50AF0C80D632450597698E2B44C378AA@us.oracle.com> <20120208192800.GA31761@acm.acm> <20120208200908.GB31761@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1328851451 29751 80.91.229.3 (10 Feb 2012 05:24:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2012 05:24:11 +0000 (UTC) Cc: Stefan Monnier , Drew Adams , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 10 06:24:10 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rvixt-0006KG-CN for ged-emacs-devel@m.gmane.org; Fri, 10 Feb 2012 06:24:09 +0100 Original-Received: from localhost ([::1]:55787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvixp-0001lR-5N for ged-emacs-devel@m.gmane.org; Fri, 10 Feb 2012 00:24:05 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvixi-0001l2-LX for emacs-devel@gnu.org; Fri, 10 Feb 2012 00:24:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvixg-0007Ae-JO for emacs-devel@gnu.org; Fri, 10 Feb 2012 00:23:58 -0500 Original-Received: from mail-ww0-f49.google.com ([74.125.82.49]:57804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvixg-0007AO-AZ for emacs-devel@gnu.org; Fri, 10 Feb 2012 00:23:56 -0500 Original-Received: by wgbdt13 with SMTP id dt13so1817285wgb.30 for ; Thu, 09 Feb 2012 21:23:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xL9KGC3T/Ix9oNnD+SGvIiZIirNI4fWMiNlAxm2ygHE=; b=iR4r1q9Q/7dN6D38+/dK3YFB0VYS6/hsbIRDGCa60DIs1bxtzHjs50/Hsmibib4yuc e2J1OOC06XWG6Efgw0twJMLbK0OMeB1N6cwlBOf+a6YL2UPu6Jtx93Wvi6erSIiRwJVR /q4R4TZU8dzphM0dcSfRhY+NiT1b+qKu9gGv4= Original-Received: by 10.180.83.97 with SMTP id p1mr6950619wiy.19.1328851435450; Thu, 09 Feb 2012 21:23:55 -0800 (PST) Original-Received: by 10.223.102.133 with HTTP; Thu, 9 Feb 2012 21:23:55 -0800 (PST) In-Reply-To: <20120208200908.GB31761@acm.acm> X-Google-Sender-Auth: Mqvi_KBDweISmOPAKASMTYMv-jc X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.49 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:148422 Archived-At: On Wed, Feb 8, 2012 at 12:09 PM, Alan Mackenzie wrote: > I think you're right. =A0Ah well. =A0I learnt this afternoon that quoting= a > macro invocation > > =A0 =A0'(foo-macro) > > doesn't stop it being expanded. =A0I don't think that's in the elisp > manual. Of course it isn't, because it's not true. Try it yourself: (defmacro foo-macro () '(message "Foo macro's code has run!")) (defmacro bar-macro (one two) `(list ,one '(foo-macro) ,two)) If you evaluate: (bar-macro "Hello" "World") You get ("Hello" (foo-macro) "World") Whereas if you changed bar-macro to: (defmacro bar-macro (one two) `(list ,one (foo-macro) ,two)) you would get: ("Hello" "Foo macro's code has run!" "World") Likewise, (foo-macro) evaluates to "Foo macro's code has run!" (and prints the message), but '(foo-macro) evaluates to (foo-macro), exactly as you would expect. -PJ Gehm's Corrollary to Clark's Law: Any technology distinguishable from magic is insufficiently advanced.