emacs-devel
[Top][All Lists]
Advanced

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

Re: string> missing?


From: Thibaut Verron
Subject: Re: string> missing?
Date: Thu, 4 Jun 2015 07:30:08 +0200

2015-06-04 0:25 GMT+02:00 Stefan Monnier <address@hidden>:
>
> > testing strings for equality in emacs lisp is already tricky enough!
>
> Now, regardless of whether I agree with the rest of what is being said
> in this thread, this part really puzzles me.  I do think there are some
> tricky/subtle issues in string equality testing in Emacs, but these are
> sufficiently subtle that most people will never know about them.
>
> So, what are you referring to here?
>

Mostly to this:

(setq str1 "foo")
(setq str2 "foo")
(setq str3 str1)
(= str1 str2)       ;;==> *error*
(eq str1 str2)      ;;==> nil
(eq str1 "foo")     ;;==> nil
(eq str1 str3)      ;;==> nil
(string= str1 str2) ;;==> t

The first two candidates for a newcomer to string testing don't return
the expected result, because = is really number=, and eq does not test
for structural equality (and is basically useless for strings, as I
understand it). Now maybe tricky is a strong word, after all it is
properly documented once you notice the issue. And I wouldn't be able
to suggest a better way of exposing these functions.

For the thread at hand, obviously if one is looking for a string>
function, one knows about string=. But I can't help but imagine a
developer running into both annoyances on the same day: the first one
has deep roots, but the second one is trivial to fix, couldn't we
spare him that?

Thibaut



reply via email to

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