[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Evaluation of macro arguments
From: |
Pascal J. Bourguignon |
Subject: |
Re: Evaluation of macro arguments |
Date: |
Tue, 05 Jan 2016 20:22:17 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Marcin Borkowski <mbork@mbork.pl> 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.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
Re: Evaluation of macro arguments,
Pascal J. Bourguignon <=