emacs-devel
[Top][All Lists]
Advanced

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

Re: Another bug with the macro counter


From: Stefan
Subject: Re: Another bug with the macro counter
Date: Sat, 30 Oct 2004 20:09:07 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (darwin)

> Quieting the byte compiler can probably also be achieved with
> (eval-when-compile (defvar edebug-active))

Hopefully such ugly hack doesn't work.
(defvar foo) only has an effect when seen by the byte-compiler, so putting
it in a `eval-when-compile' is at best pointless.

But what I was objecting to is the fact that using (defvar foo) is really
telling the byte-compiler: "look, I know you can't see it, but trust me,
this is a global or dynamically-bound variable that will be bound at
runtime, so don't warn me when I use it".

In the case of edebug-active, it is simply not true: it's a variable that
might be bound or not, which is why we test it with `boundp'.  This case is
handled in the byte-compiler by recognizing the (if (boundp 'foo) ...) form
so we know that within the first arm of the `if' the variable is bound.
We could extend this trick to also recognize (and (boundp 'foo) ...)
or even (and ... (boundp 'foo) ...) but it's clearly not necessary in
this case.

Whether (and (boundp 'foo) foo) is better stylistically than
(if (boundp 'foo) foo) is debatable, but I do know that the `if'
form is stylistically much better than the use of (defvar foo)
or (with-no-warning foo).


        Stefan




reply via email to

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