R6RS Version References
Guile’s module system includes support for locating modules based on a declared version specifier of the same form as the one described in R6RS (see R6RS Library Form in The Revised^6 Report on the Algorithmic Language Scheme). By using the #:version keyword in a define-module form, a module may specify a version as a list of zero or more exact, non-negative integers.
This version can then be used to locate the module during the module search process. Client modules and callers of the use-modules function may specify constraints on the versions of target modules by providing a version reference, which has one of the following forms:
(sub-version-reference ...)
(and version-reference ...)
(or version-reference ...)
(not version-reference)in which sub-version-reference is in turn one of:
(sub-version)
(>= sub-version)
(<= sub-version)
(and sub-version-reference ...)
(or sub-version-reference ...)
(not sub-version-reference)in which sub-version is an exact, non-negative integer as above. A version reference matches a declared module version if each element of the version reference matches a corresponding element of the module version, according to the following rules:
- The
andsub-form matches a version or version element if every element in the tail of the sub-form matches the specified version or version element. - The
orsub-form matches a version or version element if any element in the tail of the sub-form matches the specified version or version element. - The
notsub-form matches a version or version element if the tail of the sub-form does not match the version or version element. - The
>=sub-form matches a version element if the element is greater than or equal to thesub-versionin the tail of the sub-form. - The
<=sub-form matches a version element if the version is less than or equal to thesub-versionin the tail of the sub-form. - A
sub-versionmatches a version element if one iseqv?to the other.
For example, a module declared as:
(define-module (mylib mymodule) #:version (1 2 0))would be successfully loaded by any of the following use-modules expressions:
(use-modules ((mylib mymodule) #:version (1 2 (>= 0))))
(use-modules ((mylib mymodule) #:version (or (1 2 0) (1 2 1))))
(use-modules ((mylib mymodule) #:version ((and (>= 1) (not 2)) 2 0)))