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,1dd28d5040ded1f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-14 10:51:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!newscon02.news.prodigy.com!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr14.news.prodigy.com.POSTED!3bae8248!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Announce: Grace project site operational References: <4519e058.0205140718.3ddb1b2a@posting.google.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 67.115.104.217 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr14.news.prodigy.com 1021398647 ST000 67.115.104.217 (Tue, 14 May 2002 13:50:47 EDT) NNTP-Posting-Date: Tue, 14 May 2002 13:50:47 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: [[PGGTSDZRRQBQH]]RKB_UDAZZ\DPCPDLXUNNHPHBATBTSUBYFWEAE[YJLYPIWKHTFCMZKVMB^[Z^DOBRVVMOSPFHNSYXVDIE@X\BUC@GTSX@DL^GKFFHQCCE\G[JJBMYDYIJCZM@AY]GNGPJD]YNNW\GSX^GSCKHA[]@CCB\[@LATPD\L@J\\PF]VR[QPJN Date: Tue, 14 May 2002 17:50:47 GMT Xref: archiver1.google.com comp.lang.ada:24041 Date: 2002-05-14T17:50:47+00:00 List-Id: > That's the biggie. If you try to make separate types for velocities > and accelerations, you will suddenly find that you also need separate > types for times and distances, and perhaps even Hz and mass and forces > and rotational orientations and velocitites and accelerations. Then > you'll find how annoying it is to have to do type conversions on every > factor in every formula. A more attractive option may be to write your > own math operators that return the correct type given their two input > types. But that causes an exponential growth in operators that you > have to create every time you add a new unit. How about "usually use Standard.Float but rarely use Standard.Integer". Most of the times expressions mix types they are physical things, and typically floating point, while integers are usually used for things like counts and subscripts, where mixed expressions are rare. > ... automaticly generates the proper new type given the operator and > the types of its operands. How about a(nother) new Ada 0x construct: dimension optionally appended to a type declaration, eg type Seconds is new Float; type Centimeters is new Float; type Grams is new Float; type Velocity is new Float dimension Centimeters/Seconds; type Acceleration is new Float dimension Velocity/Seconds; type Dynes is new Float dimension Grams*Acceleration; t : Seconds; d : Centimeters range 0.0 .. 100.0; v : Velocity; f : Dynes; Then have the compiler allow an expression like "v*t" and have it do the dimensional analysis at compile seconds to know the result is of some declared type, in this case Centimeters. v+t is still caught as an error and, since neither a square centimeter nor an erg type have been declared, expressions like d*d and f*d are caught. > Generally, what I see Ada folk do is use *subtypes* for all this That's really orthogonal. In a program about electric cars you should be able to say type Miles is digits 4 range 0.0 .. 100.0; type Hours is new Float range 0.0 .. 2.0; type Speed is new Float range 0.0 .. 60.0 dimension Miles/Seconds;