From: Fraser <newsfraser@blancolioni.org>
Subject: Re: Safe Units Handling in Ada
Date: Wed, 22 May 2002 10:32:05 +0200
Date: 2002-05-22T08:37:00+00:00 [thread overview]
Message-ID: <3CEB5785.7050409@blancolioni.org> (raw)
In-Reply-To: u4rh1lcgm.fsf@gsfc.nasa.gov
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.
next prev parent reply other threads:[~2002-05-22 8:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-21 10:01 Safe Units Handling in Ada Fraser Wilson
2002-05-21 14:21 ` Pat Rogers
2002-05-21 15:58 ` Stephen Leake
2002-05-22 8:32 ` Fraser [this message]
2002-05-22 10:21 ` Fraser
2002-05-22 16:37 ` Stephen Leake
2002-05-23 10:16 ` Fraser
2002-05-23 16:03 ` Stephen Leake
2002-05-22 22:44 ` William C. Brennan
2002-05-23 8:55 ` Russ
2002-05-23 9:28 ` Fraser
2002-05-23 10:03 ` martin.m.dowie
2002-05-23 10:24 ` Fraser
2002-05-23 11:03 ` martin.m.dowie
2002-05-23 15:57 ` Dan Andreatta
2002-05-23 16:15 ` Fraser Wilson
2002-05-23 16:48 ` martin.m.dowie
2002-05-23 9:04 ` Russ
2002-05-23 10:01 ` Fraser Wilson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox