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,1dd28d5040ded1f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-17 08:39:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Announce: Grace project site operational Date: 17 May 2002 11:27:32 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <4519e058.0205140718.3ddb1b2a@posting.google.com> <3CE15D0A.3050100@mail.com> <3ce21f37$1@pull.gecm.com> <3CE2AB7E.AD4A9956@san.rr.com> <3CE2B842.7060705@mail.com> <3CE2F4E3.DABF19D7@san.rr.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1021649676 23063 128.183.220.71 (17 May 2002 15:34:36 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 17 May 2002 15:34:36 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:24278 Date: 2002-05-17T15:34:36+00:00 List-Id: Fraser Wilson writes: > Well, I happened to have some tools lying around that make writing > this sort of thing really easy, so I knocked together a prototype this > afternoon. It takes definitions like "unit Length in Metres", > "Velocity is Length / Time" and "Force in Newtons is Mass * > Acceleration". The result is an Ada package with a bunch of type X is > new Float declarations and all the given operations implemented (using > pragma Inline; maybe Intrinsic works too). Great! I'd like to see it. Are your tools (or at least the final tool) open source? > Unfortunately, there's a wee problem with magnitude changes; say I > add the following: > > function "*" (Left : Float; Right : Metres) return Metres; Don't use Float. Make the base float type a generic, so I can instantiate it with my own float type. That allows me to choose single or double precision, etc. And 'Metres' is spelled 'Meter' (http://physics.nist.gov/cuu/Units/units.html). Hmm, not sure whether I like the plural here or not. And my personal standard would require 'Meter_Type', but I'm willing to relax that for this package. > Then for M : Metres, M := 2.0 * M is ambiguous, because of > Standard."*" > > What's more, Standard."*" has no meaning in this domain, but there's > no way (as far as I know) of getting rid of it. You are correct that we need these "scaling" operators. I remember this problem now (I did start down this road once, a long time ago :). However, I don't mind saying M := Float_Type'(2.0) * M; The whole point is to be clear about units; bare numbers need to be qualified with the appropriate unit type, even if it is unitless. > If I don't define a magnitude changing function, then M := 2.0 * M > works, but M := F * M doesn't (for F : Float). Right, not good. > The way to fix all this would be to make the types private, and > supply conversion functions. I've always found that ugly though. Right, even worse! You lose literals for all the types. -- -- Stephe