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,43bc631fb4a56c2a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-10 15:10:48 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!uchinews!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!newspeer.cts.com!galanthis.cts.com!127.0.0.1.MISMATCH!not-for-mail Sender: kst@king.cts.com Newsgroups: comp.lang.ada Subject: Re: Unchecked_Conversion References: <9fnbtt$ild$1@e3k.asi.ansaldo.it> <41F37C284A6DE8C0.8A6A99719FF11B52.8149DC60E20677C9@lp.airnews.net> From: Keith Thompson Date: 10 Jun 2001 15:10:47 -0700 Message-ID: X-Newsreader: Gnus v5.5/Emacs 20.3 NNTP-Posting-Host: 209.68.192.180 X-Trace: 992211047 nntp.cts.com 767 209.68.192.180 Xref: archiver1.google.com comp.lang.ada:8522 Date: 2001-06-10T15:10:47-07:00 List-Id: rlove@antispam.neosoft.com (Robert B. Love ) writes: [...] > My experience runs counter to this. My employer has chosen to use > typing for every conceivable measurement. So we have type Meters, > Meters_Per_Second, Feet, Feet_Per_Second, Seconds, Watts, Volts, and so > on. > The list is endless. > > To avoid conversions I would have to have hundreds of overloaded > operators. > And to make matters worse, we have generic vectors that can be > instantiated > for the basic types above. I would have to have overloaded operators for > all the vector combinations. At some cost in efficiency, you could use a single type, say Quantity, implemented as a record that includes the units and a numeric value. Inconsistent unit errors would raise Constraint_Error rather than failing at compilation time. If you write the code carefully enough, you might even be able to replace the package that defines type Quantity with a more efficient one that doesn't do the checks (type Quantity is new Long_Float or whatever). Use the checking version during development to catch errors, and use the more efficient version (with thorough testing, of course) for the released product -- unless the checking version happens to be fast enough. Just a thought. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Cxiuj via bazo apartenas ni.