Re: Storing units in the database

From: Drago Ganic <drago.ganic_at_in2.hr>
Date: Sun, 17 Jul 2005 17:37:16 +0200
Message-ID: <dbdtvc$pp9$1_at_sunce.iskon.hr>


Marshall,

you said:
....

4) define a type m
5) define a type m^2
6) define an operation * on m that yields m^2
...

Of course this is doable. But the question is: are types "m^2", "m^3" a good and practical approach ? I don't think so. There are algebraically relationships between them. How would you relate the types "m", "m^2", "m^3"? How would we handle Kilo, Mega etc ?

I believe, as Mikito, this approach is not practical. It's not done in physics that way. There are no types in physics. Instead we use algebra on "symbols". There are no symbols in mainstream programming languages and database systems and that's not good.

Greeting from Croatia,
Drago Ganic

"Marshall Spight" <marshall.spight_at_gmail.com> wrote in message news: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 Sun Jul 17 2005 - 17:37:16 CEST

Original text of this message