help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: To `boundp' or not to `boundp'?


From: Drew Adams
Subject: RE: To `boundp' or not to `boundp'?
Date: Tue, 1 Sep 2015 13:42:25 -0700 (PDT)

> > > > I often see code like this
> > > > (when (and (boundp 'xxx-mode) xxx-mode) ...)
> > >
> > > The "proper" way to do that is to use bound-and-true-p.
> >
> > That certainly is *not* proper for the more general case
> > (and (boundp 'xxx)  xxx), where the value of `xxx' is
> > not necessarily Boolean or is not used only as a Boolean.
> >
> > Well, it works the same, but the _name misleads_ terribly
> > in this case, even if the doc does let you know that the
> > variable value (not t or nil) is returned, when bound.
> 
> The name isn't misleading if you use it in a boolean context,
> like the WHEN call in the OP.

Correct.  It is not misleading in that case.  Which is why
I qualified the statement with "where the value of `xxx' is
_not_ necessarily Boolean or is _not_ used only as a Boolean."

It does not mislead in all cases, no.  But it does in some.
It is misleading in general because what it suggests is not
what is meant in some (common) cases.  Not a great name.

FWIW, if someone proposed `member-p' instead of `member'
I would have the same remark.  The former emphasizes the
Boolean/predicate nature; the latter does not.  A fortiori,
if someone were to propose `member-and-true-p' - no thanks.

It's not a big deal, certainly.  But neither is it needed.
(and (boundp 'VAR) VAR) is succinct enough and clear enough,
IMHO, and it has the advantage of _never_ misleading.



reply via email to

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