Re: Storing units in the database

From: Marshall Spight <marshall.spight_at_gmail.com>
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

  1. define a type lbs
  2. define a type kg
  3. define implicit conversions from one to the other
  4. define a type m
  5. define a type m^2
  6. define an operation * on m that yields m^2
  7. etc for ever.

lots of work defining types, though.

Marshall Received on Wed Jul 13 2005 - 05:10:44 CEST

Original text of this message