[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26564: Document that only functions and not variables can end with "
bug#26564: Document that only functions and not variables can end with "-p"
Wed, 19 Apr 2017 15:01:04 -0700 (PDT)
> > 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
> 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
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.
bug#26564: Document that only functions and not variables can end with "-p", Drew Adams, 2017/04/19