emacs-devel
[Top][All Lists]
Advanced

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

Re: master 71783e9: Add the string-numeric-lessp function


From: Paul Eggert
Subject: Re: master 71783e9: Add the string-numeric-lessp function
Date: Sun, 21 Feb 2016 20:16:56 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

Lars Ingebrigtsen wrote:

I don't think that's something our numerical string comparison function
should be doing.

Again, I'm not sure I'm following. The two strings "2.21-0ubuntu4" and "2.21-0ubuntu4.1" are identical except the latter has ".1" appended. Shouldn't almost any sane kind of string comparison consider the shorter to be less than the longer?

If only some strings are valid for comparison, I suppose the comparison function could be a partial function, e.g., it could signal an error when given a string that it doesn't think has a valid format. This of course could be done, but it makes usage more complicated. For sorting, having comparison functions be total functions is much simpler to explain.

At least, that's been the tradition in other GNU tools. GNU ls -v applies the string-version-lessp algorithm to every pair of file names that it considers, and it works on arbitrary file names. It sounds like you may be thinking of some other tradition, although I'm not sure what that tradition would be.

The GNU ls -v approach works well in practice, because people who care about version numbers tend to name their files consistently. E.g., they do not put files "foo001.png" "foo1.png" in the same directory, because that kind of usage would confuse humans no matter what 'ls -v' does.



reply via email to

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