Why a defmacro that calls a defun?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why a defmacro that calls a defun?

Eric Abrahamsen-2
I'm poking through Gnus, and seeing a fair number of places with code
that looks like this:

(defmacro nnoo-define-skeleton (backend)
  `(eval-and-compile
     (nnoo-define-skeleton-1 ',backend)))

(defun nnoo-define-skeleton-1 (backend)
  ...)

What does this actually do? All I can see happening is that a quote mark
is added before the BACKEND argument in the macro. What is happening
here?

Thanks,
Eric


Reply | Threaded
Open this post in threaded view
|

Re: Why a defmacro that calls a defun?

Barry Margolin
In article <[hidden email]>,
 Eric Abrahamsen <[hidden email]> wrote:

> I'm poking through Gnus, and seeing a fair number of places with code
> that looks like this:
>
> (defmacro nnoo-define-skeleton (backend)
>   `(eval-and-compile
>      (nnoo-define-skeleton-1 ',backend)))
>
> (defun nnoo-define-skeleton-1 (backend)
>   ...)
>
> What does this actually do? All I can see happening is that a quote mark
> is added before the BACKEND argument in the macro. What is happening
> here?

It just causes the function to be called at compile time as well as run
time, due to the use of eval-and-compile.

--
Barry Margolin, [hidden email]
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Reply | Threaded
Open this post in threaded view
|

Re: Why a defmacro that calls a defun?

Eric Abrahamsen-2
Barry Margolin <[hidden email]> writes:

> In article <[hidden email]>,
>  Eric Abrahamsen <[hidden email]> wrote:
>
>> I'm poking through Gnus, and seeing a fair number of places with code
>> that looks like this:
>>
>> (defmacro nnoo-define-skeleton (backend)
>>   `(eval-and-compile
>>      (nnoo-define-skeleton-1 ',backend)))
>>
>> (defun nnoo-define-skeleton-1 (backend)
>>   ...)
>>
>> What does this actually do? All I can see happening is that a quote mark
>> is added before the BACKEND argument in the macro. What is happening
>> here?
>
> It just causes the function to be called at compile time as well as run
> time, due to the use of eval-and-compile.

Huh, thanks for that. I guess it's obvious, but it was not clicking for me.