From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: Evaluation of macro arguments Date: Tue, 05 Jan 2016 21:30:35 +0100 Message-ID: <87bn8z93bo.fsf@mbork.pl> References: <87fuycs35f.fsf@mbork.pl> <87h9irn85y.fsf@kuiper.lan.informatimago.com> <874merstn3.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1452025876 26973 80.91.229.3 (5 Jan 2016 20:31:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Jan 2016 20:31:16 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Pascal J. Bourguignon" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 05 21:31:00 2016 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 1aGYFu-00042f-Bf for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jan 2016 21:30:58 +0100 Original-Received: from localhost ([::1]:51402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGYFt-00007c-PV for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jan 2016 15:30:57 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGYFk-00007T-J0 for help-gnu-emacs@gnu.org; Tue, 05 Jan 2016 15:30:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aGYFh-00019B-CI for help-gnu-emacs@gnu.org; Tue, 05 Jan 2016 15:30:48 -0500 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:57964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGYFh-00018j-6L for help-gnu-emacs@gnu.org; Tue, 05 Jan 2016 15:30:45 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id BF8ED8288AF; Tue, 5 Jan 2016 21:30:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rkSMrBiZCv4u; Tue, 5 Jan 2016 21:30:36 +0100 (CET) Original-Received: from localhost (unknown [109.232.24.28]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 021F88288AA; Tue, 5 Jan 2016 21:30:35 +0100 (CET) User-agent: mu4e 0.9.13; emacs 25.1.50.1 In-reply-to: <874merstn3.fsf@mbork.pl> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 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:108627 Archived-At: On 2016-01-05, at 20:39, Marcin Borkowski wrote: > On 2016-01-05, at 20:22, Pascal J. Bourguignon wrote: > >> Marcin Borkowski writes: >> >>> Hi all, >>> >>> continuing my quest to grok macro argument evaluation issues, I'd like >>> (again) to make sure that I get it correctly. So I have this simple >>> macro generating a list of consecutive numbers (which is not without >>> problems - I am aware of those, namely (i) it uses hard-coded symbols >>> instead of generating them on the fly, and (ii) it has no error >>> checking): >>> >>> (defmacro range (from dir to) >>> `(let ((delta (cond ((eq ',dir 'upto) 1) >>> ((eq ',dir 'downto) -1))) >>> (i ,from) >>> (list nil)) >>> (while (not (= i ,to)) >>> (push i list) >>> (setq i (+ i delta))) >>> (nreverse list))) >> >> (let ((i 0)) >> (list (range i 'upto (incf i 10)) ; bam! >> i)) >> >> I hope you may debug it well. > > That's unfair, Pascal; I wrote that I'm aware of this, I know how to > make it work, and wasn't asking about it. OK, technically you win, since I didn't notice that I evaluated `to' multiple times. Still, this was not what I was asking about - though thank you for pointing that out to me. It would be rather embarassing if I missed it. Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University