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-22 01:30:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!transit.news.xs4all.nl!not-for-mail From: Fraser Newsgroups: comp.lang.ada Subject: Re: Safe Units Handling in Ada Date: Wed, 22 May 2002 10:32:05 +0200 Organization: XS4ALL Internet BV Message-ID: <3CEB5785.7050409@blancolioni.org> References: NNTP-Posting-Host: a80-126-24-12.adsl.xs4all.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news1.xs4all.nl 1022056620 5568 80.126.24.12 (22 May 2002 08:37:00 GMT) X-Complaints-To: abuse@xs4all.nl NNTP-Posting-Date: 22 May 2002 08:37:00 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2) Gecko/20020510 X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:24507 Date: 2002-05-22T08:37:00+00:00 List-Id: Stephen Leake wrote: > I've downloaded it and read the README and example.macks, and compiled > everything; looks good! Glad to hear it. > 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. Whoops. What's Force / Second mean? That should be Force * Meter I guess, and that evaluates to Joules directly. I wonder if there's a clean way of handling constants, such as the 0.5 in the kinetic energy formula. > (And yes, I did actually get out my physics text to check this :). I googled the basics, and did the derived from memory. The physics doesn't change, but the memory gets a bit 2Fe + 3O2 => 2Fe2O3. :) > Also, is there a description of the grammar allowed in .macks files? Oh, good idea. It's not at all complicated, but I'll add a description. Here's a quick version: macks-file ::= { unit-specification ';' } unit-specification ::= fundamental-unit-specification | derived-unit-specification fundamental-unit-specification ::= unit-name [ 'is' 'fundamental' ] derived-unit-specification ::= unit-name 'is' dimension-expression { 'or' dimension-expression } dimension-expression ::= unit-name operator unit-name opereator ::= '*' | '/' > 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? Yes, that would be useful. Comments are the same as Ada, by the way. I can't remember off-hand whether it's easy to extract comment text from the lexer; if not, I'll come up with some other mechanism. I agree about Intrinsic being more elegant, though I haven't tried it yet. If it works properly (and I'm sure it will), I'll switch over, or at least add an option. > In example_fail.adb, the statements > > N := Kg * MpS / S; > N := Kg * M / S / S; > > can be made to compile by adding parens: Indeed. It's unfortunate that one has to remember which units have been explicitly defined in order to place the parentheses properly, but I can't think of a clean way around that right now, and at least it's still type safe. > Finally, what is the derivation of the word "Macks"? (Meters/Moles), Amperes, Candela, (Kilograms/Kelvin), Seconds. I probably spent too much time thinking about that. :-) Thanks for the comments! cheers, Fraser.