emacs-devel
[Top][All Lists]
Advanced

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

Re: use of (defvar <foo>)


From: Stefan Monnier
Subject: Re: use of (defvar <foo>)
Date: Tue, 11 Apr 2006 14:42:58 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>>> Huh?  You don't want it compiled -- that's the point.
> [Actually, I meant the code rather than the eval result.]
>> By "compiled" I only mean that it goes through the byte-compiler (before
>> being eval'd).
> It goes through the compiler _after_ being evalled, by definition.

No, go check bytecomp.el: the code in eval-when-compile is first compiled;
then the resulting byte-code is evaluated and then the resuting value goes
through the normal processing.

It's this first compilation step before eval'ing which notices the `defvar'
and makes it that (eval-when-compile (defvar foo)) is not a complete noop.
If the contents were not compiled before evaluation, then (eval-when-compile
(defvar foo)) would have no effect whatsoever (i.e. it wouldn't silence the
byte compiler's warnings).

>> If the content of eval-when-compile were not compiled, then
>> (eval-when-compile (defvar foo)) would be 100% equivalent to a nop.

> But it isn't compiled as such.

Judge for yourself:

    (eval-when-compile . (lambda (&rest body)
                           (list 'quote
                                 (byte-compile-eval (byte-compile-top-level
                                                     (cons 'progn body))))))

`byte-compile-eval' is just the evaluation function, but
byte-compile-top-level is the normal byte-compilation function, and I'd argue
that it should be removed (and if it is removed, then (eval-when-compile
(defvar foo)) won't have any silencing effect any more).


        Stefan




reply via email to

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