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,cc4f25d878383cc,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-02 08:01:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn4feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3C0A5054.E74A82E7@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Another Idea for Ada 20XX Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sun, 02 Dec 2001 16:01:22 GMT NNTP-Posting-Host: 12.86.35.86 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1007308882 12.86.35.86 (Sun, 02 Dec 2001 16:01:22 GMT) NNTP-Posting-Date: Sun, 02 Dec 2001 16:01:22 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:17304 Date: 2001-12-02T16:01:22+00:00 List-Id: 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