[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] Re: Dimensions as types...
From: |
Ralf Hemmecke |
Subject: |
[Axiom-developer] Re: Dimensions as types... |
Date: |
Tue, 29 Aug 2006 18:58:29 +0200 |
User-agent: |
Thunderbird 1.5.0.5 (X11/20060719) |
Hi Cliff,
Looking ahead to units:
Let's say I multiply meters:Length and seconds:Time together. I want
to end up with meters*seconds:Length*Time, which is both a new unit and
a new dimensional type.
What do you think the code
main(): () == {
a: Length := 2 centimeter;
b: Time := 3 hour;
c: (Length * Time) := a * b;
import from Length * Time * Time;
d := c * 3 second;
stdout << "a = " << a << newline;
stdout << "b = " << b << newline;
stdout << "c = " << c << newline;
stdout << "d = " << d << newline;
}
that I sent before represents?
Look at the line
c: (Length * Time) := a * b;
It constructs a type Length*Time and imports the operations from that
NEW domain. Only after that import it is clear what the * on the right
hand side actually is. The * on the left and the * on the right hand
side are terribly different. The first is of type
(Dimension, Dimension) -> Dimension
and the second of type
(Length, Time) -> Length*Time;
And my code is unable to do something like
Integer * String
because neither Integer nor String is of type Dimension, so the (first)
* cannot apply.
Take your time and study my code in detail. At each step you should
understand what it is doing.
For example, do you know why I could simply write
a: Length := 2 centimeter;
? There is only a space between 2 and centimeter.
Ralf
[Axiom-developer] Re: Dimensions as types..., C Y, 2006/08/29
Re: [Axiom-developer] Re: Dimensions as types..., Martin Rubey, 2006/08/29