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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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-07 08:15:59 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: ian0kerr@my-deja.com (Ian) Newsgroups: comp.lang.ada Subject: Re: Dimensionality Checking (Ada 20XX) Date: 7 Dec 2001 08:15:58 -0800 Organization: http://groups.google.com/ Message-ID: <11bf7180.0112070815.2625851b@posting.google.com> References: NNTP-Posting-Host: 141.245.40.230 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1007741759 9794 127.0.0.1 (7 Dec 2001 16:15:59 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 7 Dec 2001 16:15:59 GMT Xref: archiver1.google.com comp.lang.ada:17573 Date: 2001-12-07T16:15:59+00:00 List-Id: "Snodgrass, Britt (NM75)" wrote in message news:... > > -----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) > I am also thinking that unit conversions could be accomplished using syntax > similar to the following example: I implemented a module in PROLOG to do automatic conversions and although the language does not have in built type checking I used constant strings. I would like to separate out the requirement needed from how Ada will impliment it. My requirement was to convert a scalar (physical quantity implemented as the product of a real number and a physical unit type). I defined this as a predicate which would return when true the same scalar in the before and after representations. e.g., :- convert(1, inch, 0.00254, metre). yes The way this was used in an algorithm was when an expression was to be evaluated the units used to define the expression were compared with the input parameter units and converted to the required type. After the expression was evaluated the units could be converted back to the original type. A typical program would be a) read inputs in arbitrary but defined units b) execute algorithms in preferred units c) convert back to original units for the user I did think of analysing the units into powers of Mass Length and Time to convert to say SI for computations, but I settled on chaining convertions using predefined conversion factors to avoid listing all the possible pairs of single step conversions. E.g. I would convert yards to feet then inches then metres. > 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 I used the module expensively in aerodynamic modelling with complete success. The use of Celsius to Kelvin was no problem and as the SI system is an ISO standard it could be linked into the Ada standard. We would then like to have a way of extending scalar types to national/industry/traditional units. May be something like type inches is metres tagged ..... but that is only an implementation idea. The challenge would be to mould this into the Ada style. I am looking forward to see how easy this is. Ian