[Ecls-list] Fwd: [ecls:bugs] #206 string-lessp does not behave as string< ignoring case
Juan Jose Garcia-Ripoll
jjgarcia at users.sourceforge.net
Fri Sep 21 19:46:32 UTC 2012
Could you people have a look at the bug report and my answer? I believe I
am right, though SBCL is reporting a different order and this (once more)
confuses users
*bugs:206 string-lessp does not behave as string< ignoring case*
*Status:* open *Created:* Thu Sep 20, 2012 09:43 PM UTC by Rafael Jesús
Alcántara Pérez *Last Updated:* Thu Sep 20, 2012 09:43 PM UTC *Owner:*
nobody
Ignoring case, this two function calls should behave the same
(«string-lessp and string-greaterp are exactly like string< and string>,
respectively, except that distinctions between uppercase and lowercase
letters are ignored. It is as if char-lessp were used instead of char< for
comparing characters.»):
(string< "a_" "aa") => 1
(string-lessp "a_" "aa") => nil
But this is not the case. Am I missing something?
STRING-LESSP is indeed implemented using CHAR-LESSP but your expectations
about how this function should behave are wrong. Note that the Common Lisp
standard states that CHAR-LESSP ignores case but it must do so not only
when both characters are alphabetic, but also when comparing alphabetic and
non-alphabetic ones.
An ordering must be transitive (A < B) and (B < X) must imply (A < X). Take
for instance #\_, #\a and #\A. We have (< #\A #\_ #\a) Now you only want
(CHAR-LESSP #\A #\a) to change value but this destroys transitivity.
The only way to achieve this with CHAR-LESSP is to convert the character
first to one case and then perform the comparison, which is what has been
done for a long time with Common Lisps.
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120921/19f2a5b0/attachment.html>
More information about the ecl-devel
mailing list