From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cc4f25d878383cc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-06 16:10:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst!enst.fr!not-for-mail From: "Snodgrass, Britt (NM75)" Newsgroups: comp.lang.ada Subject: RE: Dimensionality Checking (Ada 20XX) Date: Thu, 6 Dec 2001 17:09:20 -0700 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: avanie.enst.fr 1007683804 83575 137.194.161.2 (7 Dec 2001 00:10:04 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 7 Dec 2001 00:10:04 +0000 (UTC) To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2653.19) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:17547 Date: 2001-12-06T17:09:20-07:00 > -----Original Message----- > From: Wes Groleau [mailto:wgroleau@usa.com] > Sent: Thursday, December 06, 2001 3:39 PM > To: comp.lang.ada@ada.eu.org > Subject: Re: Dimensionality Checking (Ada 20XX) > > Britt Snodgrass wrote: > > (dimensionality) in Ada code would be most naturally implemented as > > attributes of objects or types. The units of an object or type would > > be specified with a representation clause. If unspecified, the unit > > I think this is a very good idea. But now to nitpick: > > > Accel : Magnitude; > > for Accel'Unit use > > ISO_Metric_Units.Meter / ISO_Metric_Units.Second**2; > > In some cases, might there be multiple ways to describe > the units? Speed is Acceleration * Time but it is also > Distance / Time. Yes, but the compiler would resolve both of these to a canonical form such as Distance_Unit**(1)*Time_Unit**(-1) and know that they both represent the same composite unit. I am also thinking that unit conversions could be accomplished using syntax similar to the following example: type Magnitude is digits 15; Accel_FPS2 : Magnitude; for Accel_FPS2'Unit use Goofy_Old_Units.Foot / ISO_Metric_Units.Second**2; -- feet per second per second Accel_MPS2 : Magnitude; for Accel_MPS2'Unit use ISO_Metric_Units.Meter / ISO_Metric_Units.Second**2; -- meters per second per second begin Accel_FPS2 := 32.0 -- "Feet per second squared" implied -- now convert units like this: Accel_MPS2 := Accel_FPS2 * Accel_MPS2'Unit / Accel_FPS2'Unit; -- or this: Accel_MPS2 := Accel_FPS2 * ISO_Metric_Units.Meter / Goofy_Old_Units.Foot; provided that every base unit (distance, mass, time, charge, etc.) attribute had a corresponding named number whose value was the ratio of the named unit to the ISO base unit. For example: ISO_Metric_Units.Meter := 1.0; -- value in meters ISO_Metric_Units.Kilometer := 1000.0; -- value in meters Goofy_Old_Units.Foot := 0.3048; -- value in meters This idea is still half-baked but I'll keep thinking about it. It would be nice to have some type of dimensional unit support specified in an optional Annex for Ada 200X. Britt P.S. The example in my first post should have been a "procedure", not a "package body"