comp.lang.ada
 help / color / mirror / Atom feed
From: "martin.m.dowie" <martin.m.dowie@ntlworld.com>
Subject: Re: Safe Units Handling in Ada
Date: Thu, 23 May 2002 17:48:06 +0100
Date: 2002-05-23T17:48:06+01:00	[thread overview]
Message-ID: <j39H8.1948$FZ4.136810@newsfep1-win.server.ntli.net> (raw)
In-Reply-To: 338040f8.0205230757.2150b881@posting.google.com

"Dan Andreatta" <andreatta@mail.chem.sc.edu> wrote in message
news:338040f8.0205230757.2150b881@posting.google.com...
> > The generated example.ads yields:
> > ...
> >    function "*"
> >      (Left  : Kilogram;
> >       Right : Kilogram)      -- This is good, we want it abstract.
> >      return Kilogram
> >    is abstract;
> >
>
> This also should return kg**2.

Can you set this up as another rule?

My own attempt at a Unit Generator package was allowed
users to define:
   a) which of the SI base units they wanted
   b) which of the SI derived units they wanted
   c) to define alias (ie subtypes, e.g. "subtype Area is Metre_Squared;")
of any unit
   d) to define a range of powers

This lead to a package such as:

generic
   type A_Float is digits <>;
package SI_Units is

   type Unitless is new A_Float;

   type Metre is new A_Float;
   type Metre_Squared is new A_Float;
   type Metre_Cubed is new A_Float;

   function "*" (L : Metre; R : Metre) return Metre_Squared;
   ...
end SI_Units;

The problem I found with this approach was one of line numbers when
all units are requested for the range **-3 .. **+3. Some code browsers
don't seem to like file >1200 lines long!







  parent reply	other threads:[~2002-05-23 16:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-21 10:01 Safe Units Handling in Ada Fraser Wilson
2002-05-21 14:21 ` Pat Rogers
2002-05-21 15:58 ` Stephen Leake
2002-05-22  8:32   ` Fraser
2002-05-22 10:21 ` Fraser
2002-05-22 16:37   ` Stephen Leake
2002-05-23 10:16     ` Fraser
2002-05-23 16:03       ` Stephen Leake
2002-05-22 22:44   ` William C. Brennan
2002-05-23  8:55     ` Russ
2002-05-23  9:28     ` Fraser
2002-05-23 10:03       ` martin.m.dowie
2002-05-23 10:24         ` Fraser
2002-05-23 11:03           ` martin.m.dowie
2002-05-23 15:57     ` Dan Andreatta
2002-05-23 16:15       ` Fraser Wilson
2002-05-23 16:48       ` martin.m.dowie [this message]
2002-05-23  9:04 ` Russ
2002-05-23 10:01   ` Fraser Wilson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox