[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange behavior of macro
From: |
David Kastrup |
Subject: |
Re: Strange behavior of macro |
Date: |
Tue, 30 May 2006 11:34:39 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
"Herbert Euler" <address@hidden> writes:
> Is the following in Emacs a expected behavior of macro?
>
> (defmacro m1 (v)
> (let ((len (length (eval v))))
> `(quote ,len)))
> => m1
>
> (m1 '(1 2 3))
> => 3
>
> (setq v1 '(1 2 3))
> => (1 2 3)
>
> (m1 v1)
> => 3
>
> (setq v v1)
> => (1 2 3)
>
> (m1 v)
> => error: (wrong-type-argument sequencep v)
In combination with dynamic scope, yes. m1 gets passed 'v as v, so
now v is bound to 'v and (eval v) again delivers 'v.
Evaluating a macro argument in the macro itself is often asking for
trouble. And Elisp's scoping rules don't exactly help.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum