On this page:
17.4.1 Version Number Comparison
Version
Version.to_  list
Version.to_  int
Version.is_  alpha
17.4.2 Version-Dependent Expansion
if_  at_  least
if_  at_  least
if_  at_  least
when_  at_  least
when_  at_  least
when_  at_  least
if_  racket_  at_  least
if_  racket_  at_  least
if_  racket_  at_  least
when_  racket_  at_  least
when_  racket_  at_  least
when_  racket_  at_  least
0.47+9.2

17.4 Version Numbers🔗ℹ

A valid version string 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".

17.4.1 Version Number Comparison🔗ℹ

 import: rhombus/version open package: rhombus-lib

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

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.

17.4.2 Version-Dependent Expansion🔗ℹ

 import: rhombus/version_meta package: rhombus-lib

nestable declaration

version_meta.if_at_least vers

| decl; ...

| decl; ...

 

definition

version_meta.if_at_least vers

| defn; ...

| defn; ...

 

expression

version_meta.if_at_least vers

| body; ...

| body; ...

 

nestable declaration

version_meta.when_at_least vers:

  decl; ...

 

definition

version_meta.when_at_least vers:

  defn; ...

 

expression

version_meta.when_at_least vers:

  body; ...

 

nestable declaration

version_meta.if_racket_at_least vers

| decl; ...

| decl; ...

 

definition

version_meta.if_racket_at_least vers

| defn; ...

| defn; ...

 

expression

version_meta.if_racket_at_least vers

| body; ...

| body; ...

 

nestable declaration

version_meta.when_racket_at_least vers:

  decl; ...

 

definition

version_meta.when_racket_at_least vers:

  defn; ...

 

expression

version_meta.when_racket_at_least vers:

  body; ...

 

vers

 = 

string

The version_meta.if_at_least and version_meta.when_at_least forms select a sequence of decls, defns, or bodys at expansion time, depending on whether the current Rhombus version (as reported by system.version) is at least vers. The vers must be a literal string that is a valid version string.

The version_meta.if_racket_at_least and version_meta.when_racket_at_least forms similarly select depending on whether the host Racket version (as reported by system.racket_version) is at least vers.

version_meta.when_at_least "0.1":

  use_static // not available before version 0.1

fun greet(who :~ String):

  "Hello,  " ++ who ++ "!"