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: Emanuel Berg
Subject: Re: Is there any difference between `equal' and `string=' for strings?
Date: Fri, 20 Aug 2021 08:24:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Jean Louis wrote:

> 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

Uhm, but in that case, s1, s2, and s3 are evaluated to their
string values, so at the time of `string=', that's

  (string= "Jane" "Jane") ; t
  (string= "Jane" "Doe" ) ; nil

> And of course you are free to compare empty symbols:
>
> (string= 'hi 'hi) -> t

With symbols their "print names" are used, you can get that
with

  (symbol-name 'hi) ; "hi"

So that's virtually (string= "hi" "hi") only here it is done
_by_ and not before string= (as 'hi does not evaluate to the
string "hi", for example).

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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