emacs-devel
[Top][All Lists]
Advanced

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

RE: Naming predicates


From: Drew Adams
Subject: RE: Naming predicates
Date: Fri, 28 Sep 2018 12:40:25 -0700 (PDT)

> >>    If the purpose of a function is to tell you whether a certain
> >>    condition is true or false, give the function a name that ends in
> >>    'p' (which stands for "predicate").  If the name is one word, add
> >>    just 'p'; if the name is multiple words, add '-p'.  Examples are
> >>    'framep' and 'frame-live-p'.
> 
> *Users* should never define a single-word function, since they should
> use a namespace prefix.  Hence "I'd say you can simply always use "-p"
> when it's something you define".

Users are free to do _anything_ they like. As I said, "as a user you
can use whatever you want."

And users who write Lisp, creating a predicate, are not necessarily
writing a package or library, and they might well not want to use
a "namespace prefix."

And I believe (but I don't have a reference) that RMS pointed
out that the single-word recommendation does not include
a "namespace prefix". (Logically, it should not. IMO.)

Another consideration might be a multiple-word name that is
based on an existing name. It could be helpful to keep the
same name as a part, instead of adding a hyphen. 

> You don't have to follow them when you define your own function.

You never have to follow them, if you're not providing code
for the Emacs distribution. Does even code provided for
Emacs itself _have_ to follow them? If so, clearly that "have
to" has been bypassed or missed sometimes.

> > indivisible-p interactive-p ring-p registerv-p
> > bool-vector-subsetp coding-system-lessp default-boundp file-attributes-lessp
> > hack-one-local-variable-eval-safep ...
> 
> Yes, there are conflicting desires: when you define something that's
> very much like "foop" but in the context of "strigles", the multi-word
> rule suggest you name it "strigle-foo-p", but there's also an argument
> to be made for "strigles-foop".

Yes, that's just what I meant above.

> As the author of that function you get to follow whichever of the two
> you like.  Personally, I think always using "-p" is a simpler rule and
> is never wrong (that's the rule followed by `cl-defstruct`,
> incidentally).  Even using "-p" on single-word thingies is
> perfectly acceptable.

Acceptable does not mean conventional.



reply via email to

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