Re: Storing units in the database
Date: 12 Jul 2005 20:10:44 -0700
Message-ID: <1121224244.590976.110920_at_g14g2000cwa.googlegroups.com>
Mikito Harakiri wrote:
> Marshall Spight wrote:
> >
> > I believe that C++, for example, has everything you need to
> > be able to do this sort of thing in the type system. I am
> > not aware, however, of any body of people finding it to be
> > worth the effort.
>
> Again, type system has little to offer.
>
> Adding
>
> 5 * lbs + 5 * kg
>
> is perfectly legal, although depends upon "lbs" defintion. If
>
> lbs = 0.4 * kg
>
> then we simply substitute. Then we apply distributive law. How about
> adding velocity to distance? Why not:
>
> 5 * m / c^2 + 20 * m
>
> We can apply a distributive law again
>
> (5 / c^2 + 20) * m
>
> but we fail to isolate unit symbols in a separate factor.
The C++ type system is powerful enough to
- define a type lbs
- define a type kg
- define implicit conversions from one to the other
- define a type m
- define a type m^2
- define an operation * on m that yields m^2
- etc for ever.
lots of work defining types, though.
Marshall Received on Wed Jul 13 2005 - 05:10:44 CEST