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 <> wrote:
> On Tue, Nov 8, 2011 at 21:19, Miles Bader <> 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: ' > > >
>'.  This keeps version comparisons simpler (and also allows
reverting back to beta,, if need be).