comp.lang.ada
 help / color / mirror / Atom feed
* Another Idea for Ada 20XX
@ 2001-12-02 16:01 James Rogers
  2001-12-02 16:38 ` Preben Randhol
                   ` (5 more replies)
  0 siblings, 6 replies; 26+ messages in thread
From: James Rogers @ 2001-12-02 16:01 UTC (permalink / raw)


In scientific terms a measurement is done in terms of some unit.
For instance, distance is in meters, microns, feet or furlongs.
Speed is then calculated as a distance per unit time. Acceleration
is the second derivative of speed.

I would like to have this notion of measurement units and their
relationships supported in a language. This would require the language
to perform unit analysis while performing static or run-time 
calculations. Because of the added computational overhead, there must
be a way to choose or reject unit analysis for defined types.

Perhaps a new keyword for unit-analyzed types could be introduced,
along the lines of the keyword "tagged" added to Ada 95. A unit-
analyzed type would carry its own unit description tag to 
facilitate unit analysis. Any numeric type without such a tag
would not be subject to unit analysis.

Possible declarative syntax might be:

type Meters is unit range (0.0..1.0E380);
type Hours is unit range (0.0..9.99E30);
type Speed is unit(Meters / Hours);

The advantage for the software developer is in the usage:

Vehicle_Speed : Speed;
Track_Distance : Meters;
Lap_Time : Hours;

Speed := Track_Distance / Lap_Time;

This approach would allow the appropriate mixing of data types, which
is currently forbidden by Ada, in a meaningful and correct manner.

I know this proposal places a heavy burden upon compiler writers.
I also suspect it would be very useful for ensuring the correctness
of programs, particularly in embedded systems. 

Note that a lot of the unit analysis could be performed statically.
This would allow minimal performance penalty at run time.

Jim Rogers
Colorado Springs, Colorado USA



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

end of thread, other threads:[~2001-12-07 22:51 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-02 16:01 Another Idea for Ada 20XX James Rogers
2001-12-02 16:38 ` Preben Randhol
2001-12-02 22:26   ` James Rogers
2001-12-02 21:19 ` Patrick Hohmeyer
2001-12-02 21:26 ` Lutz Donnerhacke
2001-12-02 23:49   ` Patrick Hohmeyer
2001-12-03  6:06     ` Wilhelm Spickermann
2001-12-03  8:58     ` Lutz Donnerhacke
2001-12-03 13:40     ` Thomas Koenig
2001-12-03  0:21 ` Robert C. Leif, Ph.D.
2001-12-03  0:35 ` Robert Dewar
2001-12-03  1:33   ` James Rogers
2001-12-03 12:34     ` Dirk Dickmanns
2001-12-04 19:02       ` Unit handling (was: Another Idea for Ada 20XX) Wilhelm Spickermann
2001-12-03 14:56 ` Another Idea for Ada 20XX Mark Lundquist
2001-12-03 15:12   ` Lutz Donnerhacke
2001-12-03 21:13     ` Dimensionality Checking (Ada 20XX) Nick Roberts
2001-12-04 14:00       ` Dmitry A. Kazakov
2001-12-06 19:52         ` Britt Snodgrass
2001-12-06 20:55           ` Mark Lundquist
2001-12-06 22:38           ` Wes Groleau
2001-12-06 23:12             ` Mark Lundquist
2001-12-07 14:36               ` Wes Groleau
2001-12-07  9:37           ` Dmitry A. Kazakov
2001-12-07 22:51           ` Mark Lundquist
2001-12-03 17:00   ` Another Idea for Ada 20XX chris.danx

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