[Top][All Lists]

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

Re: use of (defvar <foo>)

From: Dave Love
Subject: Re: use of (defvar <foo>)
Date: Sun, 09 Apr 2006 14:56:23 +0100
User-agent: Gnus/5.11 (Gnus v5.11)

Stefan Monnier <address@hidden> writes:

>>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).

Huh?  You don't want it compiled -- that's the point.  You're actually
considering changing what eval-when-compile does and breaking more
existing code??  Anyway, the point is that Gnus is supposed to be
supporting Emacs 21 (and XEmacs), the eval-when-compile DTRT
everywhere, and Emacs 22 looks rather a forlorn hope.  The
compatibility stuff is typically ugly, but this idiom isn't.

> 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
> byte-compiled.

That's the point.  Without the wrapper it prevents you using the
load-history mechanisms reliably (as I was trying to do to contribute
to Gnus).

> 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).

Actually, such usage was fixed widely in Emacs 21 because it caused
trouble -- try to test a change by unloading a feature and render your
session unusable.

reply via email to

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