lua-users home
lua-l archive

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

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 ''.

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'.