lua-users home
lua-l archive

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


On Tue, Nov 8, 2011 at 11:35 PM, HyperHacker <hyperhacker@gmail.com> wrote:
> On Tue, Nov 8, 2011 at 21:19, Miles Bader <miles@gnu.org> wrote:
>> I think a simple "version_compare" function (version_greater, whatever)
>> would be more straight-forward; indeed, something like that already
>> exists in GNU libc -- strverscmp.  The basic idea is:  compare
>> lexigraphically, but compare any embedded integers as numbers.
> Isn't that generally called natural compare? It's used by smart file
> browsers too so that file10.jpg doesn't list before file2.jpg.

Looks so [1].  If the comparison function we use for _VERSION is also
useful for natural order comparisons in general, that would be a plus.

One thing this will not always handle, unlike that Python scheme [2],
is pre-release tags [3] like '5.2.0-beta1 < 5.2.0'.  Personally, I've
been moving away from using those to instead putting the stability
level *after* the version: '5.2.0.5 > 5.2.0.4rc > 5.2.0.3b > 5.2.0.2b
> 5.2.0.1a'.  This keeps version comparisons simpler (and also allows
reverting back to beta, 5.2.0.6b, if need be).

[1] http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html
.
[2] http://www.python.org/dev/peps/pep-0386/
[3] http://en.wikipedia.org/wiki/Software_versioning#Pre-release_versions