GNU bug report logs -
#26564
Document that only functions and not variables can end with "-p"
Previous Next
Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>
Date: Wed, 19 Apr 2017 15:48:01 UTC
Severity: wishlist
Tags: fixed
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 26564 <at> debbugs.gnu.org (full text, mbox):
> > 3. Is there a proposal for a _different_ naming convention
> > for Boolean variables? I'd argue that we should have some
> > such a naming convention. And I'd argue that it should be
> > different for options and non-option variables.
>
> That's a good point indeed.
>
> An alternative to "-p" would be "is-", like `foo-is-negative'.
Not great for cases where "has-" would be more appropriate (and
vice versa, for cases where "is-" would be more appropriate).
Not good for lots of other cases too.
E.g., `box-cursor-when-idle-p' or `use-foo-bar-p' or
`remove-foo-props-p' or `iac1-was-cycling-p' or
`foo-names-only-p' or `hl-line-when-idle-p'?
I suggest we stay away from helper verbs (or even any words).
Verbs, in particular, can be different for singular and plural
(e.g. `fancy-candidates-p').
> Not using -p would also have an advantage: you could distinguish
> boolean variables from variables bound to a predicate function.
How is it difficult to distinguish those if `-p' is used for
both?
It's true that in some (very few) contexts just looking at
"'foo-p" in some code might not let you know whether `foo-p'
is a variable or a function (or is both), but it is trivial
to find out which is the case, for any symbol that is already
defined as a variable or a function.
This bug report was last modified 5 years and 218 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.