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,a5f77772dc1375a3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-21 09:04:11 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: Safe Units Handling in Ada Date: 21 May 2002 11:58:33 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1021997136 396 128.183.220.71 (21 May 2002 16:05:36 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 21 May 2002 16:05:36 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:24471 Date: 2002-05-21T16:05:36+00:00 List-Id: Fraser Wilson writes: > After a recent discussion, I put together Macks, a small program that > generates Ada packages for dealing with physical units in a type safe > way. I've downloaded it and read the README and example.macks, and compiled everything; looks good! One quibble; example.macks says "Energy is Force / Second;". In the real world, there is no simple relationship among Energy, Force, and Second. Energy is Joules = kg m^2 / s^2; Force is Newtons = kg m / s^2. You can have "Energy is Kilogram * Square_Velocity or Force * Meter;". (And yes, I did actually get out my physics text to check this :). Also, is there a description of the grammar allowed in .macks files? I assume I could work it out by reading the Ada code, but a user-readable description would be useful. Hmm, looks like the only thing missing from example.macks is "or", and if you use my definition of Energy above, you get that (assuming I used "or" correctly). So maybe that's enough; just add some comments to example.macks. Looking at the output of "macks example.macks", I'd like a way to put in a copyright notice; maybe have macks copy the first contiguous comment in the source file? Did you try using "pragma Import (Intrinsic, "*")", instead of providing a body? That sounds like a good idea to me. Looking at the assembly code generated by gnatmake -O3 -gnatn example_success -cargs -save-temps there are no function calls for "*", so pragma Inline is enough. But 'pragma Import (Intrinsic)' seems more elegant, and may save compilation time, which may or may not be an issue. In example_fail.adb, the statements N := Kg * MpS / S; N := Kg * M / S / S; can be made to compile by adding parens: N := Kg * (MpS / S); N := Kg * ((M / S) / S); I agree it would be nice if the parens were not necessary, but I don't mind them. Finally, what is the derivation of the word "Macks"? -- -- Stephe