Figure 11.

NUMERIC_UNITS example.

------------------------------------------------------------ -- Sometimes trying to make a generic unit too universal is -- more trouble than it is worth. Here's what happens if you -- try to combine the integer and floating dimensional -- packages. (This is just the beginning of trouble.) with STANDARD_INTEGERS; generic type Numeric_type is private; with function "-"(RIGHT : Numeric_type) return Numeric_type is <>; with function "+"(LEFT, RIGHT : Numeric_type) return Numeric_type is <>; with function "-"(LEFT, RIGHT : Numeric_type) return Numeric_type is <>; with function "*"(LEFT, RIGHT : Numeric_type) return Numeric_type is <>; with function "/"(LEFT, RIGHT : Numeric_type) return Numeric_type is <>; with function "/"(LEFT, RIGHT : Numeric_type) return STANDARD_INTEGERS.Integer_32; with function "/"(LEFT, RIGHT : Numeric_type) return float; with function "abs"(RIGHT : Numeric_type) return Numeric_type is <>; with function "rem"(LEFT, RIGHT : Numeric_type) return Numeric_type is <>; with function "mod"(LEFT, RIGHT : Numeric_type) return Numeric_type is <>; with function ">"(LEFT, RIGHT : Numeric_type) return boolean is <>; with function ">="(LEFT, RIGHT : Numeric_type) return boolean is <>; with function "<"(LEFT, RIGHT : Numeric_type) return boolean is <>; with function "<="(LEFT, RIGHT : Numeric_type) return boolean is <>; package NUMERIC_UNITS is type Units is new Numeric_type; -- These functions convert pure numbers into -- dimensioned quantities, and vice versa. function Type_Convert(X : Numeric_type) return Units; function "+"(X : Numeric_type) return Units; function "-"(X : Numeric_type) return Units; -- These are all the arithmetic functions you need. function "+"(RIGHT : Units) return Units; function "-"(RIGHT : Units) return Units; -- and so on end NUMERIC_UNITS;