[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54639: 26.1; (not (string-empty-p nil)) returns true
From: |
Lars Ingebrigtsen |
Subject: |
bug#54639: 26.1; (not (string-empty-p nil)) returns true |
Date: |
Thu, 31 Mar 2022 13:26:56 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
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