Subject: bug#54639: 26.1; (not (string-empty-p nil)) returns true

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 31 Mar 2022 13:26:56 +0200

Ernesto Alfonso <[email-masked]> 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