[Top][All Lists]

[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: Fri, 07 Apr 2006 16:45:43 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> Could people on emacs-devel please comment on this?
> Should we use (defvar <foo>) or (eval-when-compile (defvar <foo>)) in Gnus
> for compatibility with Emacs 21?  (Probably the same holds for MH-E.)

>From the future's point of view (Emacs-22 and up), placing such defvars
inside eval-when-compile is a bad practice (in the future it may even fail
to work since there's nothing that guarantees that the content of
eval-when-compile is actually compiled rather than just eval'd).

In Emacs-21 and older, such a defvar will have some undesirable minor
side-effects (via the load-history) unless it is placed inside an
eval-when-compile *and* the file is byte-compiled.  Indeed placing the
defvar inside the eval-when-compile has no effect if the file is not

I'd recommend to not use eval-when-compile since that's what many packages
have been doing for many years without suffering much (if ever) of the
occasional side-effects (which only affect unload-feature and sometimes
C-h v).

But it's your call, really.


reply via email to

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