From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Macro Expansion Inconsistency Date: Tue, 16 Dec 2014 13:46:30 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1418766434 25066 80.91.229.3 (16 Dec 2014 21:47:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Dec 2014 21:47:14 +0000 (UTC) Cc: Alexander Shukaev To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 16 22:47:08 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y0zxT-0003ko-01 for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Dec 2014 22:47:07 +0100 Original-Received: from localhost ([::1]:46947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0zxS-0003BM-Cr for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Dec 2014 16:47:06 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0zxG-0003B4-3J for help-gnu-emacs@gnu.org; Tue, 16 Dec 2014 16:46:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0zxD-0007TZ-U4 for help-gnu-emacs@gnu.org; Tue, 16 Dec 2014 16:46:54 -0500 Original-Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:35091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0zxD-0007TF-OZ for help-gnu-emacs@gnu.org; Tue, 16 Dec 2014 16:46:51 -0500 Original-Received: by mail-oi0-f45.google.com with SMTP id a141so10272098oig.18 for ; Tue, 16 Dec 2014 13:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=pPvm5Uo8I3oRXaZlZ8t72A0+qLBhs6ay9zP64OWx2pw=; b=krWpO3QxSGFalw5v5g1edr90dArVeRMrxU7Ms4RQZ/NPs+JyoacUbzvZD7TJfliekL zSkxM0ZihFNJiZkY9qrVE+bb2ejPmeQO7d74VoruVZa/3VF5T6NwnDwFtNqZXiXU3l7z KFYjjxQlp0Ny7gjUPhgirKvEE4Ys+O5MmTPs4ryRbudC9BR9j6/MYwf0I5Yy2/wEl1MQ nCaJ/D3FFGItMBEgN2Ow3ugK5AF/8QvglaHZ69W5ts8B/pOCEy++iSsDsvKFtZUlHwLC KovSyWMR8w2q7p8wXlvMw5ZoA6wy/rW7wEq8CARn/5JxgDBj5SGxBkv1bVLmTmdzJxHN oD9Q== X-Received: by 10.202.75.81 with SMTP id y78mr22545246oia.80.1418766410780; Tue, 16 Dec 2014 13:46:50 -0800 (PST) Original-Received: by 10.76.12.162 with HTTP; Tue, 16 Dec 2014 13:46:30 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::22d X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101609 Archived-At: Alexander Shukaev wrote: > > Just consider when exactly the different parts of your macro are > > evaluated. When is something that is quoted in the definition evaluated? > > And when is something that is comma-escaped evaluated? Then look > > carefully at what is quoted and what is comma-escaped. You'll see that > > in the first version, something doesn't match. > > > If I would want to think more myself I would not ask for help. Could you > just explain if you know? (defmacro test (name) `(let* ((name ',name) (symbol (intern (concat "some" "-" (symbol-name name))))) ,symbol)) ^^^^^^^ The comma operator causes something to be evaluated when the macro is expanded, but the `symbol' binding doesn't exist until runtime (at which time it exists where the macro expanded, not within the macro's body). This is another version that will work (notice the lack of quoting): (defmacro test (name) (let ((symbol (intern (concat "some" "-" (symbol-name name))))) symbol)) --- john