Thanks for all the replies.

I'm nervous about fixing the arity of Unit, in any language used for
commercial applications.

Herbert Graeber writes:
 > [...]
 > 
 > Using C++, one can define templates for proper handling of units without
 > additional language extensions:
 > 
 >     template <int l, int t>
 >     class Unit {
 >         ...
 >     };
 > 
 > [...]

Christian Sievers writes:
 > [...]
 > 
 > >  sqrt  ::  (m::Int)  |->  (l::Int)  |->  (t::Int)  |->
 > >            Unit (2*m) (2*l) (2*t)  ->  Unit m l t
 > 
 > [...]

The S.I. units are stable.  However, currency units benefit from the
same treatment, with each currency as a separate dimension (assuming
that compilers should not be exchange rate aware), and a commercial
application may need to deal with any number of currencies.

Then, there's the issue of letting the end users define additional
currencies at run time.  I see a couple of ways to deal with this:

  1. Don't attempt to type-check currency at compile time.  Fix the
     arity of Unit after all, if that helps with anything.

  2. Deem the currency-defining task to be programming, not a true end
     user activity.  Deem your application's configuration parameters
     to be a programming language.

Regards,
Tom


Reply via email to