lua-users home
lua-l archive

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


On Tue, Nov 8, 2011 at 21:19, Miles Bader <miles@gnu.org> wrote:
> David Manura <dm.lua@math2.org> writes:
>> It is a trade-off.  The main intention of the zero padding is to allow
>> versions to be compared by simple string comparison, i.e. without any
>> external version library like verlib [1].
>>
>>   local B = require 'baz'
>>   local V = require 'verlib'
>>   if V(B._VERSION) >= V'1.2.5' then
>>        -- as opposed to just `B._VERSION >= '001.002.005'`
>>    . . .
>>   else
>>     . . .
>>   end
>>
>> Implementing verlib in Lua would also be a valid approach though.
>> Should we bother?  With git, we just accept unfriendly version numbers
>> (e.g. 8d1985807b).
>
> 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.
>
> -Miles
>
> --
> Friendship, n. A ship big enough to carry two in fair weather, but only one
> in foul.
>
>

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.

-- 
Sent from my toaster.