unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Ernesto Alfonso <erjoalgo@gmail.com>
Cc: 54639@debbugs.gnu.org
Subject: bug#54639: 26.1; (not (string-empty-p nil)) returns true
Date: Thu, 31 Mar 2022 13:26:56 +0200	[thread overview]
Message-ID: <874k3e8irj.fsf@gnus.org> (raw)
In-Reply-To: <874k3fza1w.fsf@debianx1e> (Ernesto Alfonso's message of "Wed, 30 Mar 2022 12:20:43 -0400")

Ernesto Alfonso <erjoalgo@gmail.com> writes:

> The expression (not (string-empty-p nil)) returns true. This is very
> conuterintuitive: nil is as "empty" a value as there is!

But nil isn't a string, and the function is only (meant to be) valid for
strings.  It "works" for symbols by accident.

> Some of the more reasonable alternatives I can think of in order of
> preference are:
>
> 1. (string-empty-p nil) simply returns t
> 2. (string-empty-p nil) raises a type error

We can't change how an established function works -- that would break
people's code.

> 3. subr-x.el provides a separate string-null-or-empty-p function

That would be just (zerop (length OBJECT)), which doesn't quite seem
worth having a function when the function name is longer than the
expression it replaces.  (And it would be misleading to have the
function name start with string- since it works on other things, too.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





      reply	other threads:[~2022-03-31 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 16:20 bug#54639: 26.1; (not (string-empty-p nil)) returns true Ernesto Alfonso
2022-03-31 11:26 ` Lars Ingebrigtsen [this message]

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=874k3e8irj.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=54639@debbugs.gnu.org \
    --cc=erjoalgo@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).