comp.lang.ada
 help / color / mirror / Atom feed
* Re: Macks - adding unit constants?
@ 2003-11-06  9:58 christoph.grein
  0 siblings, 0 replies; 12+ messages in thread
From: christoph.grein @ 2003-11-06  9:58 UTC (permalink / raw)
  To: comp.lang.ada

> >   Dist: constant SI := 0.000_86 * Meter;
> > or
> >   Dist: constant SI := 0.86 * Milli * Meter;
> 
> This is in some ways more to my taste.  Here there are no conversions of 
> dimensionless numbers to dimensioned numbers.  But I prefer the 
> compile-time checking I get with Macks to the run-time checking implied 
> in the above examples.

Compile time checking will only work for simple cases satisfactorily.

How are you going to handle fractional powers? (See my paper).
How power series?
Every now and then you will run into problems because a certain overloading of 
multiplication operators is not available and you have to reorder your 
expression in order to make it compile.
With Macks, you still have the wrong overloadings (e.g. T*T giving T for any 
type T) still present, albeit abstract, and those _can_ screw up overloading 
resolution under certain conditions.

ARG has abandoned a proposal for Ada05 that would have added unit checking at 
compile time because of the many problems that come with it. (One of the authors 
was Tucker Taft.)

If you really want dimension checking in full generality (my personal feeling 
is, it's not worth it, real software problems are buried somewhere else, see Ada 
Europe Conference 2003, Springer Verlag *), you need a run-time method where 
dimensions can easily be switched off when the code has been subject to 100% 
coverage unit testing (because then you have _proved_ that all equations are 
dimensionally correct).

(*) I can send you the PDF file if you're interested.

Christoph Grein



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Macks - adding unit constants?
@ 2003-11-03 11:57 christoph.grein
  2003-11-05 23:38 ` Jacob Sparre Andersen
  0 siblings, 1 reply; 12+ messages in thread
From: christoph.grein @ 2003-11-03 11:57 UTC (permalink / raw)
  To: comp.lang.ada

> As opposed to what?  It still doesn't tell which units we are working
> in.  Dimensionless numbers should not be able to suddenly become
> dimensioned numbers without som kind of explicit conversion.

Why not:

   Dist: constant Meter := +0.000_86;

Or use Dmitry Kazakov's or my method:

  Dist: constant SI := 0.000_86 * Meter;
or
  Dist: constant SI := 0.86 * Milli * Meter;

See http://home.T-Online.de/home/Christ-Usch.Grein/Ada/

You'll find references to four methods to use dimensioned items (one of them of 
course Macks).



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Macks - adding unit constants?
@ 2003-10-20 11:08 christoph.grein
  0 siblings, 0 replies; 12+ messages in thread
From: christoph.grein @ 2003-10-20 11:08 UTC (permalink / raw)
  To: comp.lang.ada

Have also a look at:


http://home.t-online.de/home/Christ-Usch.Grein/Ada/Contents.html
http://home.t-online.de/home/Christ-Usch.Grein/Ada/Dimension.html
http://home.t-o
nline.de/home/Christ-Usch.Grein/Ada/SI.html



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Macks - adding unit constants?
@ 2003-10-09  7:57 Jacob Sparre Andersen
  2003-10-14 16:01 ` Stephen Leake
  0 siblings, 1 reply; 12+ messages in thread
From: Jacob Sparre Andersen @ 2003-10-09  7:57 UTC (permalink / raw)


I have just started to use Macks to generate packages for handling 
physical units.  I like the tool, but I would appreciate some method for 
handling different proportional units like km, m and mm _in_ Macks.  I 
also find writing:

    Diameter := 3.0 * mm;
    Diameter := 0.003 * m;

more appealing than:

    Diameter := 0.003;
    Diameter := Meter (0.003);

I considered if changing the declaration of fundamental units from:

    Meter is fundamental;

to:

    Meter is fundamental Length;

naming the type "Length" and not "Meter", but declaring a constant 
"Meter" of type "Length".

Since "Unit * Integer" is reserved for declaring vectors, we need some 
other syntax for declaring derived units.  Could:

    mm := 0.001 * Meter;

be used?  Or should I just put the derived units in a separate package?

Jacob
-- 
"There is nothing worse than having only one drunk head."




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-11-06  9:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-06  9:58 Macks - adding unit constants? christoph.grein
  -- strict thread matches above, loose matches on Subject: below --
2003-11-03 11:57 christoph.grein
2003-11-05 23:38 ` Jacob Sparre Andersen
2003-10-20 11:08 christoph.grein
2003-10-09  7:57 Jacob Sparre Andersen
2003-10-14 16:01 ` Stephen Leake
2003-10-17 20:23   ` Jacob Sparre Andersen
2003-10-20 14:48     ` Preben Randhol
2003-11-03 11:45       ` Jacob Sparre Andersen
2003-11-03 14:24         ` Preben Randhol
2003-10-20 19:06     ` Stephen Leake
2003-11-03 11:45       ` Jacob Sparre Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox