emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macro vs Function


From: David Kastrup
Subject: Re: Macro vs Function
Date: Wed, 12 Apr 2006 11:53:25 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Herbert Euler" <address@hidden> writes:

>>From: David Kastrup <address@hidden>
>>To: "Herbert Euler" <address@hidden>
>>CC: address@hidden
>>Subject: Re: Macro vs Function
>>Date: Wed, 12 Apr 2006 11:24:16 +0200
>>
>>Which two programs?
>
> If I define a "program" as a macro or function definition followed by
> an application to this macro or function, there were four "programs"
> included in my last post (except the definition of "g", which is an
> introduction to functions refered in "programs").
>
>>There is a difference between calling a macro directly, and compiling
>>a function refering to a macro.
>
> So the behavior is same, but when compiling there are slight
> differences?

The behavior is not the same.  When a function call gets executed, the
arguments are first evaluated and then the call is made.  When a macro
call gets executed, the arguments are quoted, the macro gets called,
and the resulting form gets evaluated.

Here is your original claim:

> After reading defmacro and eval in eval.c, I conclude that, in
> Emacs Lisp, if I substitute "defmacro" at the beginning of
> definition of a macro with "defun" and quote each argument in the
> call the behavior of code will not be altered.  Is this correct?

Now take a look:

(defmacro xxx (a) a)
(defun yyy (a) a)

(xxx (+ 3 4)) => 7
(yyy '(+ 3 4)) => (+ 3 4)

So even when not compiling, your description is wrong.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

[Prev in Thread] Current Thread [Next in Thread]