help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Elisp string function question


From: Robert Pluim
Subject: Re: Elisp string function question
Date: Fri, 18 Jun 2021 16:54:26 +0200

>>>>> On Fri, 18 Jun 2021 17:23:56 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Robert Pluim <rpluim@gmail.com>
    >> Cc: help-gnu-emacs@gnu.org
    >> Date: Fri, 18 Jun 2021 16:02:07 +0200
    >> 
    >> >> Then itʼs buggy:
    >> >> 
    >> >> (let ((s (make-symbol "")))
    >> >> (string-empty-p s))
    >> >> => t
    >> 
    Eli> Is it?  What is the name of the symbol created there?
    >> 
    >> The name is "", but the symbol itself has no value, so string-empty-p
    >> should not say t

    Eli> But if the documentation will say that string-empty-p accepts symbols
    Eli> and uses their name, then the name of this symbol _is_ empty.

Yes. But it doesnʼt say that. And I find it surprising.

    >> (let ((s (make-symbol "")))
    >> (message s))
    >> =>
    >> Debugger entered--Lisp error: (wrong-type-argument stringp ##)
    >> message(##)
    >> (let ((s (make-symbol ""))) (message s))
    >> (progn (let ((s (make-symbol ""))) (message s)))
    >> eval((progn (let ((s (make-symbol ""))) (message s))) t)
    >> 
    >> Compare this with:
    >> 
    >> (let ((s ""))
    >> (string-empty-p s) => t
    >> (message "string '%s'" s)) => no complaints from 'message'

    Eli> This is because 'message' does NOT allow symbols as its first
    Eli> argument.

It was intended to illustrate the state of 's'.

Robert
-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]