From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: Dimensionality Checking (Ada 20XX)
Date: Sun, 9 Dec 2001 22:58:11 -0000
Date: 2001-12-09T22:58:11+00:00 [thread overview]
Message-ID: <9v0qai$bs584$1@ID-25716.news.dfncis.de> (raw)
In-Reply-To: 9v0crt$bo2bi$1@ID-25716.news.dfncis.de
Some details.
Fixed point types and objects would have the attribute Unit, of type
Ada.Units.Unit_Type. A 'unit' (a value of this type) has two (notional or
actual) components: its 'dimensionality', of type Ada.Units.Dimensionality,
obtainable by the function Dim; and its 'scaling', of type universal_real,
obtainable by the function Scaling.
The types Ada.Units.Unit_Type and Ada.Units.Dimensionality would be 'static'
subtypes: a constant of such a subtype whose initial value is static, is
itself static.
The Ada.Units package would include (in addition to what I said in my
previous post):
function "*" (Left: Unit_Type; Right: universal_integer) return
Unit_Type;
function "*" (Left: universal_integer; Right: Unit_Type) return
Unit_Type;
function "/" (Left: Unit_Type; Right: universal_integer) return
Unit_Type;
function "/" (Left: universal_integer; Right: Unit_Type) return
Unit_Type;
function "**" (Left: Unit_Type; Right: universal_integer) return
Unit_Type;
function Scaling (The_Unit: in Unit_Type) return universal_real;
type Dimensionality is private;
function Dim (The_Unit: in Unit_Type) return Dimensionality;
For the (explicit) conversion between two unit-specific (fixed point) types,
their dimensionalities must be the same. Conversion between a unit-specific
and a non-unit-specific type entails no dimensionality check.
The value of Scaling(T'Unit) for any non-unit-specific fixed point type T is
always 1.0.
For the value conversion:
T1(X)
where X is of type T2, where T1 and T2 are both fixed point, the value of
the result would be the value of X*Scaling(T1'Unit)/Scaling(T2'Unit).
For the view conversion (an actual parameter):
T1(X)
where X is of type T2, where T1 and T2 are both fixed point, the value
passed in (to the subprogram being called) would be the value of
X*Scaling(T1'Unit)/Scaling(T2'Unit), and the value passed out (back into X)
would be the value of X*Scaling(T2'Unit)/Scaling(T1'Unit).
There would be the following extra rules for the predefined multiplication
and division operations. For multiplication:
function "*"(Left: in universal_fixed;
Right: in universal_fixed) return universal_fixed;
the value of the result is the value of
(Left*Scaling(Left'Unit))*(Right*Scaling(Right'Unit)), and, if the expected
type is unit-specific, it must have the same dimensions as
Dim(Left'Unit*Right'Unit).
For division:
function "/"(Left: in universal_fixed;
Right: in universal_fixed) return universal_fixed;
the value of the result is the value of
(Left*Scaling(Left'Unit))/(Right*Scaling(Right'Unit)), and, if the expected
type is unit-specific, it must have the same dimensions as
Dim(Left'Unit/Right'Unit).
For predefined exponentiation of any fixed point type T1, the function
declaration becomes:
function "**"(Left: in T1;
Right: in Integer'Base) return T2;
the value of the result is the value of (Left*Scaling(Left'Unit))**Right,
and, if the type T1 is unit-specific, T2 is an anonymous fixed point type
which is the same as T1 except that it has the dimensions of
Left'Dimensionality**Right (otherwise T2 is identical to T1).
In all other cases the semantics are as in Ada 95.
--
Best wishes,
Nick Roberts
next prev parent reply other threads:[~2001-12-09 22:58 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-07 0:09 Dimensionality Checking (Ada 20XX) Snodgrass, Britt (NM75)
2001-12-07 16:15 ` Ian
2001-12-09 17:58 ` Nick Roberts
2001-12-09 22:58 ` Nick Roberts [this message]
2001-12-10 0:17 ` Mark Lundquist
2001-12-10 1:51 ` James Rogers
2001-12-10 3:33 ` Nick Roberts
2001-12-10 19:09 ` Nick Roberts
2001-12-11 8:20 ` Thomas Koenig
2001-12-11 15:37 ` Nick Roberts
2001-12-11 20:18 ` Thomas Koenig
2001-12-12 0:58 ` Mark Lundquist
2001-12-12 8:19 ` Wilhelm Spickermann
2001-12-12 14:21 ` Stephen Leake
2001-12-12 19:10 ` Nick Roberts
2001-12-13 19:04 ` Stephen Leake
2001-12-13 22:56 ` Nick Roberts
2001-12-14 0:11 ` Nick Roberts
2001-12-14 22:14 ` Mark Lundquist
2001-12-15 1:30 ` Nick Roberts
2001-12-10 20:22 ` Thomas Koenig
2001-12-10 17:21 ` Wes Groleau
2001-12-10 19:51 ` Mark Lundquist
2001-12-10 19:56 ` Wes Groleau
2001-12-10 20:37 ` Mark Lundquist
2001-12-10 18:56 ` Nick Roberts
2001-12-11 15:05 ` Wes Groleau
2001-12-11 16:39 ` Stephen Leake
2001-12-11 19:05 ` Nick Roberts
2001-12-11 22:50 ` Mark Johnson
2001-12-12 1:59 ` Nick Roberts
2001-12-11 23:01 ` Stephen Leake
2001-12-12 2:21 ` Nick Roberts
2001-12-12 14:16 ` Stephen Leake
2001-12-13 19:52 ` Nick Roberts
2001-12-13 22:22 ` Nick Roberts
2001-12-14 6:40 ` Robert C. Leif, Ph.D.
2001-12-14 17:30 ` Stephen Leake
2001-12-14 17:38 ` Stephen Leake
2001-12-11 22:45 ` Mark Lundquist
2001-12-12 1:42 ` Nick Roberts
2001-12-12 15:17 ` Mark Lundquist
2001-12-12 14:03 ` Stephen Leake
2001-12-12 9:35 ` Dmitry A. Kazakov
2001-12-12 14:26 ` Stephen Leake
2001-12-13 17:02 ` daniele andreatta
2001-12-13 19:06 ` Stephen Leake
2001-12-14 10:16 ` Dmitry A. Kazakov
2001-12-14 22:01 ` Nick Roberts
2001-12-17 11:10 ` Dmitry A. Kazakov
2001-12-17 12:16 ` Thomas Koenig
2001-12-17 14:30 ` Dmitry A. Kazakov
2001-12-27 17:18 ` Steven Deller
2001-12-15 7:07 ` Steven Deller
2001-12-17 12:31 ` Dmitry A. Kazakov
2001-12-17 13:46 ` Thomas Koenig
2001-12-17 15:00 ` Dmitry A. Kazakov
2001-12-17 16:38 ` Thomas Koenig
2001-12-17 21:07 ` Britt Snodgrass
2001-12-20 13:44 ` Dmitry A. Kazakov
2001-12-13 19:33 ` Mark Lundquist
2001-12-13 22:15 ` Nick Roberts
2001-12-14 20:20 ` Mark Lundquist
2001-12-10 23:31 ` Mark Lundquist
2001-12-10 13:57 ` Ian
2001-12-10 17:24 ` Wes Groleau
2001-12-10 20:38 ` Britt Snodgrass
-- strict thread matches above, loose matches on Subject: below --
2001-12-11 13:11 Mike Brenner
2001-12-11 17:03 ` Mark Lundquist
2001-12-02 16:01 Another Idea for Ada 20XX James Rogers
2001-12-03 14:56 ` Mark Lundquist
2001-12-03 15:12 ` Lutz Donnerhacke
2001-12-03 21:13 ` Dimensionality Checking (Ada 20XX) Nick Roberts
2001-12-04 14:00 ` Dmitry A. Kazakov
2001-12-06 19:52 ` Britt Snodgrass
2001-12-06 20:55 ` Mark Lundquist
2001-12-06 22:38 ` Wes Groleau
2001-12-06 23:12 ` Mark Lundquist
2001-12-07 14:36 ` Wes Groleau
2001-12-07 9:37 ` Dmitry A. Kazakov
2001-12-07 22:51 ` Mark Lundquist
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox