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,1901f265c928a511 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!wns13feed!worldnet.att.net!attbi_s02.POSTED!53ab2750!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Typing in Ada References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 24.6.132.82 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s02 1086164377 24.6.132.82 (Wed, 02 Jun 2004 08:19:37 GMT) NNTP-Posting-Date: Wed, 02 Jun 2004 08:19:37 GMT Organization: Comcast Online Date: Wed, 02 Jun 2004 08:19:37 GMT Xref: controlnews3.google.com comp.lang.ada:1014 Date: 2004-06-02T08:19:37+00:00 List-Id: >Second, when the answer is that it should be read as "Count at least 100 >Apples," then the following coding "trick" is very useful: > >type Required_Apples is range 0..100; -- 1..100 was pretty dodgy too... >type Apple is range 0..Required_Apples'Base'Last; > >That allows software range checking to be omitted at least on the upper bound, OTOH, it means you don't know what the actual upper bound is. More than once during testing I've gotten something like "Constraint_Error, offending value = 101". If you used type Apple_Count is range 0 .. 100; type Orange_Count is range 0 .. 101; then you immediately know the problem is an overflowing apple count, not an orange count. An "offending value = 256" would be less informative.