On this page:
Version
Version.to_  list
Version.to_  int
Version.is_  alpha
0.45+9.1

17.4 Version Number Comparison🔗ℹ

 import: rhombus/version package: rhombus-lib

A veneer that recognizes valid version strings and adjusts comparison operators like < to compare as versions instead of plain strings.

A valid version following Racket conventions has one of the following forms:

  • ‹maj›.‹min›

  • ‹maj›.‹min›.‹sub›

  • ‹maj›.‹min›.‹sub›.‹rel›

subject to the following constraints:

  • ‹maj›, ‹min›, ‹sub›, and ‹rel› are all canonical decimal representations of Nats (i.e., decimal digits with no leading 0 unless exactly 0);

  • ‹rel› is not 0;

  • ‹sub› is not 0 unless ‹rel› is included;

  • ‹min› has no more than two digits;

  • ‹sub› and ‹rel› have no more than three digits.

The constraints force version numbers to be in a canonical form. For example, a would-be version string "4.3.0" must be written instead as "4.3", "4.3.1.0" must be written instead as "4.3.1", and rhombus("4") must be written as "4.0".

method

method (vers :: Version).to_list() :: List.of(Nat)

Parses a version into four component integers.

method

method (vers :: Version).to_int() :: Nat

Converts a version into a single integer where ordering on the integers reflects ordering on the converted versions.

method

method (vers :: Version).is_alpha() :: Boolean

Reports whether a version represents an “alpha” version.

A version number of the form ‹maj›.‹min›, ‹maj›.‹min›.‹sub›, or ‹maj›.‹min›.‹sub›.‹rel›, is an “alpha” version if ‹min› is 90 or more, ‹sub› is 900 or more, or ‹rel› is 900 or more.