Figure 5.

Dimensional units example.

------------------------------------------------------------ -- Ada can spot equations that are dimensionally incorrect -- and add correct conversion factors at compile time. -- D_U_EX.ada with STANDARD_INTEGERS, DIM_INT_32; procedure Dimensional_Units_Example is type Feet is new DIM_INT_32.Units; type Meters is new DIM_INT_32.Units; A, B, C : Feet; X, Y, Z : Meters; function Units_Convert(M : Meters) return Feet is use STANDARD_Integers; -- for multiply DISTANCE : Integer_32; begin -- 1 meter is approximately 3 feet. DISTANCE := 3 * Dimensionless(M); return Type_Convert(DISTANCE); end Units_Convert; begin A := B + C; X := Y + Z; A := B + Y; -- this line (25) is wrong A := B + Units_Convert(Y); end Dimensional_Units_Example; ------------------------------------------ The above code is in a file called D_U_EX.ada. When you compile it, here's what you get: C:>ada D_U_EX.ada Meridian AdaVantage(tm) Compiler [v2.1 Feb 29, 1988] Target 8086 "D_U_EX.ada", 25: type of function does not match context "+" [LRM 6.4] 28 lines compiled. 1 error detected.