[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "defmacro" and "local variables" and "let" and "nconc" strange behav
From: |
Le Wang |
Subject: |
Re: "defmacro" and "local variables" and "let" and "nconc" strange behaviour... |
Date: |
Mon, 14 Jan 2013 00:45:38 +0800 |
On Sun, Jan 13, 2013 at 11:00 PM, Oleksandr Gavenko <gavenkoa@gmail.com> wrote:
> On 2013-01-13, Barry Margolin wrote:
>
>> In article <mailman.17290.1358086558.855.help-gnu-emacs@gnu.org>,
>> Oleksandr Gavenko <gavenkoa@gmail.com> wrote:
>>
>>> I wrote simple macro:
>>>
>>> (defmacro my-filter (pred list)
>>> "Construct list with elements from LIST which satisfy PRED."
>>> (let ( (r (make-symbol "r_")) )
>>> `(let ( (,r '(nil)) )
>>> (mapc (lambda (item)
>>> (when (,pred item)
>>> (nconc ,r (cons item nil))))
>>> ,list)
>>> (cdr ,r))))
>>> [...]
>>> Why instead of '(nil) I get something else?
>>
>> Because nconc is destructively modifying its own source code.
>
> I know that nconc destructive. But how this effect '(nil) in defmacro inside
> `(...)?
In lisp, code is data. See my enlightenment process:
http://comments.gmane.org/gmane.emacs.bugs/50783
--
Le