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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public From: "Pat Rogers" Subject: Re: Is there a language that Dijkstra liked? (was: Re: Software landmines (loops)) Date: 1998/10/28 Message-ID: <718lct$qk1$1@supernews.com>#1/1 X-Deja-AN: 406160713 References: X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: newsabuse@supernews.com X-Trace: 909629661 Y6JRGRJUHDEA8C640C usenet53.supernews.com Organization: Software Arts & Sciences Newsgroups: comp.lang.ada Date: 1998-10-28T00:00:00+00:00 List-Id: John Woodruff wrote in message ... >>>>>> "Pat" == Pat Rogers writes: >In article <712r19$rs5$1@supernews.com> "Pat Rogers" writes: > > > Ehud Lamm wrote in message ... > >> On Mon, 26 Oct 1998 dennison@telepath.com wrote: > > > > > >> Still - Remember you can achieve all the run time checking > > functionality > >> in any language. It is just that in some languages you have to > >> code > > it > >> explicitly. But you want your code to be of quallity - you just > > have to do > >> it. > > > > Explicitly coded checks come at a price, though, that > > language-defined checks may be able to avoid. ...... > >Another consideration occurs when the programmer offers to code his >(her) own checks, in defense against the kind of errors that Ada's >checking prevents: > > > ...... In Ada, the fact > > that the check is defined by the language means that we don't > > explicitly write the it ourselves, and the optimizer then has > > freedom to help us with performance. Ironic, isn't it? > >The programmer is setting out to write additional code, and that code >itself is susceptible to some defects. Shouldn't we worry that these >defects injected into the *checking* code might lower the quality of the >product? Yes, any "extra" code is unfortunate, since it is just that much more that can go wrong. One does have to be careful, though. Consider: function Next( This : Some_Discrete_Type ) return Some_Discrete_Type is begin return Some_Discrete_Type'Succ(This); exception when Constraint_Error => return Some_Discrete_Type'First; end Next; Although the language will check that we don't "go off the end of the world" when This is Some_Discrete_Type'Last, if some poor maintenance programmer comes along and suppresses the check we are in for Trouble. In such cases the explicit, hand-coded check is preferable, IMHO: function Next( This : Some_Discrete_Type ) return Some_Discrete_Type is begin if This = Some_Discrete_Type'Last then return Some_Discrete_Type'First; else return Some_Discrete_Type'Succ(This); end if; end Next;