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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f43e6,899fc98b2883af4a X-Google-Attributes: gidf43e6,public X-Google-Thread: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-19 17:55:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!feed2.news.rcn.net!rcn!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Reply-To: "James S. Rogers" From: "James S. Rogers" Newsgroups: comp.lang.java.advocacy,comp.object,comp.lang.ada,comp.software-eng References: <9fa75d42.0304230424.10612b1a@posting.google.com> <9fa75d42.0305130543.60381450@posting.google.com> <254c16a.0305140549.3a87281b@posting.google.com> <9fa75d42.0305141747.5680c577@posting.google.com> <1053027582.984315@master.nyc.kbcfp.com> <3ec4b5c5$1@news.wineasy.se> <254c16a.0305160930.40bb42f9@posting.google.com> <9fa75d42.0305181502.53703035@posting.google.com> Subject: Re: Logic Errors and Ada (Was: A big hairy thread on Ada, Quality, and Drivers) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Tue, 20 May 2003 00:55:05 GMT NNTP-Posting-Host: 12.86.39.143 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1053392105 12.86.39.143 (Tue, 20 May 2003 00:55:05 GMT) NNTP-Posting-Date: Tue, 20 May 2003 00:55:05 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.java.advocacy:64215 comp.object:63715 comp.lang.ada:37542 comp.software-eng:19306 Date: 2003-05-20T00:55:05+00:00 List-Id: "Anders Wirzenius" wrote in message news:Za_xa.22$lF1.17@read3.inet.fi... > "James S. Rogers" wrote in message > news:wzWxa.88930$cO3.6074665@bgtnsc04-news.ops.worldnet.att.net... > > > Ada user defined numeric types are more than simply the different > > sized ints and floating point types in C and C++. C and C++ give you > > no easy way to define a type that truly fits the problem. For instance, > > if you are monitoring voltages that must always be between -5.0 and > > +5.0 volts, you can define the following type: > > > > type Voltages is digits 15 range -5.0..5.0; > > > > This defines a floating point type with a 15 decimal digits of > > precision and a valid range of values from -5.0 through 5.0. > > Any attempt to evaluate a value outside that range will result in > > a Constraint_Error exception being raised. > > Marc A. Criley showed in message > news:254c16a.0305091127.42ec7b21@posting.google.com > > an even better way to do that, viz.: > > Extreme_Voltage : constant := 5.0; > type Voltages is digits 15 range -Extreme_Voltage..+Extreme_Voltage; I guess it is a matter of taste. The definition of Extreme_Voltage adds nothing to the information known to the compiler. It also forces a symmetric set of values. To use that pattern for assymmetric values I would need to define two constants: Low_Voltage : constant := -5.0; High_Voltage : constant := 7.0; type Voltages is digits 15 range Low_Voltage..High_Voltage; Now, I cannot see the definition of the range boundaries without finding the definitions of Low_Voltage and High_Voltage. The only place I can see how such an approach would make good sense is if the range is defined by data read from a configuration file or database: function Low_Voltage return Long_Float; function High_Voltage return Long_Float; Jim Rogers