lua-users home
lua-l archive

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


On 8 November 2011 16:27, David Manura <dm.lua@math2.org> wrote:
> I propose the following scheme for the _VERSION [1] variable in modules:
>
>  dotnum ::= [0-9] [0-9] [0-9]
>  version ::=  dotnum { '.' dotnum }
>
> Examples of valid versions include '001', '001.234', and '012.001.001.001'.
>
> Properties of scheme include
>
>  - Versions can be compared by simple string comparison (no special parsing).
>  - Versions can contain an arbitrary number of dotted numbers
>    (though typically 2 - 4).
>  - By using strings, it is not subject to numerical rounding, like storing
>    versions in floating point numbers, and it even works when Lua is compiled
>    with an integer number type.
>  - Dotted numbers are unlikely ever to wrap around (exceed 999).  In the rare
>    case you do get to '001.999', then either do '001.999.001' or '002.000'.
>    If you get to '999.999.999.999' (which is only of theoretical concern)
>    then either rename your project (starting at version zero again)
>    or use '999.999.999.999.001'.
>  - Hopefully keeping things simple this way avoids the path of Perl [2].
>  - Version numbers remain relatively readable and also sort nicely.
>  - The project name is *not* included in _VERSION
>    (e.g. unlike _VERSION = "Copas 1.1.7").
>
> Some optionally allowed variants might include
>
>  - It's not required to stick with three digits per dotted number,
> except for the
>    first one.  Say you have a pre-1.0 release that versions only with the
>    date stamp.  You could use '000.2011.11.07' as long as you follow this
>    date scheme when the first dotted number is '000'.  When you
>    increment the first dotted number to '001', you may follow a different
>    scheme like '001.000'.  Simple string comparisons must still work:
>    '001.000.000' > '000.2011.11.07'.
>  - It's not required to only allow numbers.
>    1.0beta2 might be expressed like '000.999.b2'.  String comparisons still
>    work.  For example, '001.000' > '000.999.b2' > '000.999.a3'.
>
> [1] http://lua-users.org/wiki/ModuleVersioning
> [2] http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/
> [3] http://en.wikipedia.org/wiki/Dot-decimal_notation
>
>

I think a system where everything is a number would be much better:
 - They can be used directly in comparisons without any forethought
 - They can be almost arbitrarily large (as long as it fits in a double)

They don't need any regulations; as they are a native lua type - to
check if a module conforms you can just use type(mod._VERSION) ==
"number"