unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, Lars Ingebrigtsen <larsi@gnus.org>,
	Drew Adams <drew.adams@oracle.com>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: master 2bb0703 1/2: lisp/*.el: Force non-nil result to t, to match docstring
Date: Thu, 17 Oct 2019 14:02:49 -0400	[thread overview]
Message-ID: <jwvv9sntg0i.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAAeL0SSewBR91pY9RiNsUwU99RyrT3W0Jzw_tDUsWqz4Xjr_0g@mail.gmail.com> (Juanma Barranquero's message of "Thu, 17 Oct 2019 17:43:36 +0200")

Just to be clear: this is a typical bikeshed subject.

Some people think functions that return booleans should return nil/t and
other think they should return nil/non-nil.  It's a question
of opinion.  There are advantages on both sides.

So far, AFAIK most of the code and docstrings use nil/non-nil, AFAICT
(which is why we're all familiar with the notion of "non-nil" as
a matter of fact) and as a maintainer I've made an effort to try and
standardize on this, e.g. by fixing docstrings which overspecified the
return value to `t`.

This is similar to the issue of documenting side-effecting function's
return value versus discouraging the use of their return value.

The most important thing is to try and choose one and stick to it, both
for the benefit of consistency and to avoid back-and-forth
cosmetic changes.


        Stefan


Juanma Barranquero <lekktu@gmail.com> writes:

> The issue here is not transforming every "predicate" -p function into one
> returning t/nil. That's not what my patches did. And in my original answer
> I already said that most predicates return t/nil, but not *all*. I would
> contend that "predicates" not returning t/nil aren't really predicates, but
> that's a discussion for another day.
>
> Most of my latest patches make the function follow its documented interface
> (the docstring), which shouldn't be so controversial. In fact, if some
> function relied on the documented t result, if was risking getting
> something different, often in obscure cases. So I'd say this patch will
> help uncover bugs. (I'd be surprised that a function, for example,
> documented as "return t", returning a marker in *some* cases, is being used
> purposely so by the client code.)
>
> In other cases, they fix problems; either because the docstring says that
> it returns t, but in fact they return a useful non-nil value, or because
> the functions say non-nil/nil, but are in fact functions that, but it's
> very nature, will always return only t/nil. That shouldn't be
> controversial, either.
>
> I mean, if some specific change in my patches is a mistake, let's discuss
> it or fix it. But mostly, what I've done is fixing latent bugs, either in
> the documentation or the code.




  reply	other threads:[~2019-10-17 18:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<20191017004602.22269.2935@vcs0.savannah.gnu.org>
     [not found] ` <<20191017004604.866DF20BC2@vcs0.savannah.gnu.org>
     [not found]   ` <<875zkonpqm.fsf@gnus.org>
     [not found]     ` <<CAAeL0SSg8_9vELEeH9BtC02Bpf26AVCgLhpsBSAgQ0nLzXtrMw@mail.gmail.com>
     [not found]       ` <<871rvcnmg1.fsf@gnus.org>
     [not found]         ` <<8336frdcs9.fsf@gnu.org>
2019-10-17 15:15           ` master 2bb0703 1/2: lisp/*.el: Force non-nil result to t, to match docstring Drew Adams
2019-10-17 15:43             ` Juanma Barranquero
2019-10-17 18:02               ` Stefan Monnier [this message]
2019-10-17 18:18                 ` Juanma Barranquero
2019-10-17 18:31                   ` Stefan Monnier
2019-10-17 18:37                 ` Eli Zaretskii
2019-10-17 19:29                   ` Stefan Monnier
     [not found] <20191017004602.22269.2935@vcs0.savannah.gnu.org>
     [not found] ` <20191017004604.866DF20BC2@vcs0.savannah.gnu.org>
2019-10-17  1:08   ` Lars Ingebrigtsen
2019-10-17  1:44     ` Juanma Barranquero
2019-10-17  2:19       ` Lars Ingebrigtsen
2019-10-17  2:26         ` Juanma Barranquero
2019-10-17  2:49           ` Ergus
2019-10-17  3:45             ` Juanma Barranquero
2019-10-17  3:47               ` Lars Ingebrigtsen
2019-10-17  3:59                 ` Juanma Barranquero
2019-10-17  7:57         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvv9sntg0i.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).