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,FREEMAIL_FROM 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!news.moat.net!border1.nntp.sjc.giganews.com!nntp.giganews.com!local1.nntp.sjc.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 02 Jun 2004 00:28:09 -0500 Date: Wed, 02 Jun 2004 01:28:08 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Typing in Ada References: <2i1t1lFij4g5U1@uni-berlin.de> <9ZRuc.8410$hB2.7017@nwrdny03.gnilink.net> <40BCE5E8.4040305@tidorum.fi> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-kPi4+t8lwePv+nMyeU+euxyHPKJa7pVjzbch3cQK2NDA0O5ozWq+iYzy7Q/3B+B1Lw13G/ttGirY6d9!WTU/awBd+HO/29qR+NE3ZqgRBg2XwQl92XkCarR5KiMeMniYdn8ThaOURFg13Q== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: controlnews3.google.com comp.lang.ada:1013 Date: 2004-06-02T01:28:08-04:00 List-Id: Wes Groleau wrote: > In a way, you are correct. But why must we put > so much effort into preventing behavior that is > not prohibited just because it is not required? > > Does the specification say ... ? > "The program shall not tolerate apple counts higher than 100" > > Did some domain expert persuade the programmers that 101 apples > was not reasonable? > > In other words, when a specification says > "A count of 100 must be supported," the > programmers should NOT mentally rewrite it > to "Counts larger than 100 must not be supported." There are two issues here. The first I just posted about. If the requirements document is meaningful and maintained, the question about 101 Apples needs to get asked, and answered. 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, and the real upper bound is set to whatever the hardware supports for the type chosen by the compiler for Required_Apples. It also makes clear what the requirement being satisfied is. Incidently you can vary this technique and make either Required_Apples a subtype of some integer type, or make Apples a subtype of Required_Apples. There are cases when one or the other is more appropriate. -- Robert I. Eachus "The terrorists rejoice in the killing of the innocent, and have promised similar violence against Americans, against all free peoples, and against any Muslims who reject their ideology of murder. Their barbarism cannot be appeased, and their hatred cannot be satisfied. There's only one way to deal with terror: We must confront the enemy and stay on the offensive until these killers are defeated." -- George W. Bush