From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Naming predicates Date: Fri, 28 Sep 2018 15:26:24 -0400 Message-ID: References: <20180925021527.10418.61555@vcs0.savannah.gnu.org> <20180925021528.9A119204E8@vcs0.savannah.gnu.org> <87bm8lanwu.fsf@gmx.de> <87o9ck6270.fsf@gmx.de> <2cfc5ca3-d661-f431-397a-705682ab17eb@cs.ucla.edu> <877ej5ap0o.fsf@gmx.de> <3356af4b-f6f5-e353-6162-a5fa8880d223@cs.ucla.edu> <2a1f7389-0248-4920-ba11-ecc0b6aaee22@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538162730 11293 195.159.176.226 (28 Sep 2018 19:25:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 28 Sep 2018 19:25:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 28 21:25:26 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5yOE-0002rT-9m for ged-emacs-devel@m.gmane.org; Fri, 28 Sep 2018 21:25:26 +0200 Original-Received: from localhost ([::1]:45536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yQK-0003CA-Tl for ged-emacs-devel@m.gmane.org; Fri, 28 Sep 2018 15:27:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yPP-0003C5-QX for emacs-devel@gnu.org; Fri, 28 Sep 2018 15:26:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5yPK-0003VJ-SY for emacs-devel@gnu.org; Fri, 28 Sep 2018 15:26:39 -0400 Original-Received: from [195.159.176.226] (port=34460 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5yPK-0003V1-Lb for emacs-devel@gnu.org; Fri, 28 Sep 2018 15:26:34 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g5yNB-0001XZ-PA for emacs-devel@gnu.org; Fri, 28 Sep 2018 21:24:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 39 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:nptl2qEO0DjrYG4xNpgNaq0hKkE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230117 Archived-At: >> 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". > Thanks for the pointer; I'd forgotten that. But there are several > counterexamples: You don't have to follow them when you define your own function. > 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". 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. > The Common Lisp influence seems to be causing a lot of Elisp code to violate > the guideline, which may help to explain why I can never remember it. While the inconsistency is annoying when trying to reference an existing function, the situation is much simpler when you're defining a new function. Stefan