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

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

Re: Is there any difference between `equal' and `string=' for strings?


From: Marcin Borkowski
Subject: Re: Is there any difference between `equal' and `string=' for strings?
Date: Tue, 24 Aug 2021 16:55:56 +0200
User-agent: mu4e 1.1.0; emacs 28.0.50

On 2021-08-20, at 07:25, Jean Louis <bugs@gnu.support> wrote:

> * Emanuel Berg via Users list for the GNU Emacs text editor 
> <help-gnu-emacs@gnu.org> [2021-08-20 02:04]:
>> Marcin Borkowski wrote:
>> 
>> > Well, of course a string and a symbol can never be `equal',
>> > but they can be `string='. But what if both arguments
>> > are strings?
>> 
>> ... and if both arguments are symbols?
>> 
>> (string= 'hi 'hi) ; t
>> 
>> (Why ever one would use `string=' for that.)
>> 
>> Yeah, it is a jungle all that ...
>
> How I understand it, it is good also for comparison of symbols as
> strings. 
>
> (setq s1 "Jane") ⇒ "Jane"
> (setq s2 "Jane") ⇒ "Jane"
> (setq s3 "Doe") ⇒ "Doe"
>
> Then this is how I understand the intended purpose:
>
> (string= s1 s2) ⇒ t
> (string= s1 s3) ⇒ nil
>
> And of course you are free to compare empty symbols:
>
> (string= 'hi 'hi) ⇒ t
>
> However by looking at the purpose it becomes all logical to me.

It can even do (string= "hello" 'hello) => t
(Why could that be useful, I'm not sure.)

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

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