Re: WG: SI Units - has Ada missed the boat?



Grein, Christoph (Fa. ESG) wrote:
One of my pet hopes for Ada2005 was that it would include some method
of automatically checking systems of units at compilation time or with
minimal run-time checking. Alas it was voted down due to time


I have to admit that I was the main perpetrator who killed that
proposal.


Is anyone still working on an Ada solution to this?


I don't think so, if you mean a method to include in the Ada standard.


Back in the 80's I was working on a simulator, where we the software people wrote the infrastucture and the various subject area specialists wrote the code for the things they wanted to simulate.

We (software weenies) created a package (wish I could remember the name of it) that provided basic types LENGTH_UNITS, TIME_UNITS, SPEED_UNITS,
DISTANCE_UNITS, TEMPERATURE_UNITS, ANGLE_UNTIS, etc. and then defined all of the overloaded operators to convert between those.

The upshot of this was the convers stuff got so large and complec that we wrote a program that would read a text file that would define the conversions i.e. LENGTH_UNITS = SPEED_UNITS * TIME_UNITS... etc, the program then was able to define the base conversion and the related conversions ( SPEED_UNITS = LENGTH_UNITS / TIME_UNITS ), etc.
I don't remember the details but there was also a way to define the conversion from various units into the generic _UNITS. For instance for LENGTH_UNITS, METERS would = 1, feet would be whatever the conversion from feet to meters is, furlongs would be defined similarly.

This program would then write the ADA specs and bodies for the conversion.


Down side :

This was in 1986ish. The "UNITS" package took about 4 hours to compile (on a VAX using VAX ADA) and every component took a long time to compile because every expression had to be compared to the myriad of overloads to determine if the expression was valid.
If a conversion didn't exist, you added the appropriate info to the conversion file (and hope you did it right), checked it back into CM, and the build ran overnight. The next morning you could compile your expression.

Up side :
We NEVER had unit conversion issues, as the unit analysis was done by the compiler.

This enabled the subject matter experts to write code that
defined a value of type say mytime : TIME_UNITS, and myspeed : SPEED_UNITS, mydistance : LENGTH_UNITS (sorry rusty ADA syntax) and then
mytime := FROM_FOTNIGHTS ( 10.0 ) ;
myspeed := FROM_METERS_PER_SECOND ( 100.0 ) ;
mydistance = myspeed * mytime ;

PRINTLN ( TO_FURLONGS ( mydistance ) ) ;

and
myint : INTEGER ;

myint = 10 ;
mydistance = myspeed * myint ; would not compile.

You can see why the conversion package got so big... it had to defein ALL valid conversions.

Sorry this was so long. Wish I could remember more of the details
It was one of the most fun ADA jobs I worked on.

Joe Simon
WB2JQT






.



Relevant Pages

  • Re: Microsoft Losing Interest in C#?
    ... > The code doesn't compile right now because, IIRC, the JCLA generated a few ... > javaisms in the sections where a direct conversion wasn't possible. ... The JLCA doesn't understand the Comparable interface, ... UUID.cs: error CS0246: The type or namespace name 'MessageFormat' ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [ANNOUNCE] high-res-timers patches for 2.6.6
    ... but all are compile in. ... >>I would have to redo the conversion code. ... can, at boot time, switch to one of the standard clocks and thus disable HRT (or ... I had not considered not using the APIC timer if it was available. ...
    (Linux-Kernel)
  • 50 years of progress in the language
    ... almost every program would compile and run correctly using ... Smaller length alphabetic test onstant strings were treated as ... Conversion between integer variabless and equivalent digit strings ... the character array and the character string. ...
    (comp.lang.fortran)
  • Re: fast and accurate in mixed mode operations
    ... < double using the command dble() in the expressions or would it be ... For the same conversion, the speed and accuracy should be ... precision, then you might need a conversion function. ... There used to be questions about constant conversion at compile ...
    (comp.lang.fortran)
  • Re: binanry comparison mismatch
    ... conversion of VB source code to compiled native code. ... More properly called excode at this ... When a native code compile is ...
    (microsoft.public.vb.general.discussion)