[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding String to Beginning of Lines
From: |
Stefan Monnier |
Subject: |
Re: Adding String to Beginning of Lines |
Date: |
Tue, 10 Nov 2020 17:31:02 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> If you look at the definition:
>
> (defsubst string-empty-p (string)
> "Check whether STRING is empty."
> (string= string ""))
FWIW, I agree with Louis on this one: (equal string "") is shorter and
just as clear as (or even more clear than) `(string-empty-p string)`,
so I'm no fan of such a definition.
> | (defun rcd-string-empty-p (s)
> | "Returns T if string is empty or NIL"
> | (let ((s (if (null s) "" s)))
> | (if (stringp s)
> | (if (zerop (length s)) t nil))))
>
> That's more or less the same as
>
> (defun rcd-string-empty-p (s)
> (or (null s) (and (stringp s) (zerop (length s)))))
BTW since (length nil) is zero, this can be reduced in most cases to
(zerop (length s)), the main difference being that the shorter
definition signals an error if passed an object that's neither an array
nor a proper list.
> But why handling an empty list specially, and not other empty sequences,
> like the empty vector? That's what `seq-empty-p' in seq.el does, btw.
Indeed,
Stefan
- Re: Adding String to Beginning of Lines, (continued)
- Re: Adding String to Beginning of Lines, Jean Louis, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/10
- Re: Adding String to Beginning of Lines, Jean Louis, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/10
- Re: Adding String to Beginning of Lines, Jean Louis, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, Jean Louis, 2020/11/17
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/17
- Re: Adding String to Beginning of Lines,
Stefan Monnier <=
- RE: Adding String to Beginning of Lines, Drew Adams, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, tomas, 2020/11/10
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11
- Re: Adding String to Beginning of Lines, tomas, 2020/11/11
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Christopher Dimech, 2020/11/11
- Re: Adding String to Beginning of Lines, Michael Heerdegen, 2020/11/11