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: Sat, 21 Aug 2021 01:12:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>   (defun do-something (method)
>     (when (string= method "now")
>       (message "I'm all over it") ))

What about

(defun get-string (s)
  (if (stringp s)
      s
    (let ((val (symbol-value s)))
      (or (and (stringp val) val)
          (symbol-name s) ))))

(defun string== (s1 s2)
  (string= (get-string s1)
           (get-string s2) ))

(defvar one)
(setq one nil)
(string== "one" "one") ; t
(string== 'one  "one") ; t

(defvar two)
(setq two "one")
(string== 'two  "one") ; t
(string== two   "one") ; t, confusing

(setq one "two")
(string== one "one") ; nil
; argh ...

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




reply via email to

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