ranges

ranges

Specialize a code snippet for a set of ranges.

Usage:

#pragma CMOD amend range NAME [bound1 … ]

Here bounds should be numeric and admissible for a < operator, or the special string else. The bounds should be sorted with respect to that ordering.

A copy of the code snippet enclosed in its own block is created for each bound, plus a fallback version if the bound else is in the list. Within each of these copies the string ${NAME} is replaced by the actual bound within that copy. In the fallback version ${NAME} is replaced by NAME, so not much is gained, there.

If else is not in the list, and thus there is no fallback version, you can add a fallback just after the closing pragma:

#pragma CMOD done
#else {
// code for the general case, greater or equal to the last bound
}

Coding and configuration

The following code is needed to enable the sh-module framework.

SRC="$_" . "${0%%/${0##*/}}/import.sh"

Imports

The following sh-modules are imported:

Details