emacs-devel
[Top][All Lists]
Advanced

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

Re: Why (substring "abc" 0 4) does not return "abc" instead of an error?


From: Andreas Schwab
Subject: Re: Why (substring "abc" 0 4) does not return "abc" instead of an error?
Date: Mon, 16 Jul 2012 09:38:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Juanma Barranquero <address@hidden> writes:

> BTW, for unexpected behavior wrt strings, my favourite is this one
> (it's not a bug);
>
> (let ((s "ab") (m 2)) (eq (substring s 0 m) (substring s 0 m))) => nil
> (let ((s "ab") (m 1)) (eq (substring s 0 m) (substring s 0 m))) => nil
> (let ((s "ab") (m 0)) (eq (substring s 0 m) (substring s 0 m))) => t

That's not much different from ("foo" == "foo") in C.  Using eq for
comparing non-atoms is seldom useful.

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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