As The Language Specification describes User can register a unit system at run time. And pnuts.ext.UnitSystem class is a sample implementation of such pluggable module.
The implementation consists of the following codes.
For example, the following script defines a unit system. When a unit system is defined, the symbols in the first array parameter are registered as unit symbols.
UnitSystem( ["mm", "cm", "m", "km"], [1, 10, 1000, 1000000] )
In this case, a result of a unit expression is a pnuts.lang.Numeric object. Arithmetic operations can be applied to the quantities with same dimension.
1mm ==> 1mm 1mm + 1cm ==> 11.000mm
The following scripts are demo of these classes.