Contents    Page-10    Prev    Next    Page+10    Index   

Units in Programming Languages

It is possible to incorporate units into the type system, make legal conversions automatically, and detect errors:


>(gldefun test ( (x (units real meter))
                 (z (units real inch)) )
            (z = x) )

result type: (UNITS REAL INCH)
(LAMBDA (X Z) (SETQ Z (* 39.37007874015748 X)))




(gldefun testb ( (x (units real meter))
                 (z (units real kilogram)) )
           (z = x) )

glisp error detected in function TESTB
Cannot convert METER to KILOGRAM
in expression: (Z = X)