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,FROM_LOCAL_NOVOWEL, INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Xref: utzoo comp.lang.c:29578 comp.lang.ada:3965 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu Newsgroups: comp.lang.c,comp.lang.ada Subject: Re: bug me now / bug me later Message-ID: <23471:Jun1405:22:1090@kramden.acf.nyu.edu> Date: 14 Jun 90 05:22:10 GMT References: <811@sagpd1.UUCP> <7498@fy.sei.cmu.edu> Distribution: usa Organization: IR List-Id: In article <7498@fy.sei.cmu.edu> firth@sei.cmu.edu (Robert Firth) writes: > In article <811@sagpd1.UUCP> jharkins@sagpd1.UUCP (Jim Harkins) writes: > > a. for(i = SIZE; i != 0; i -= STEP) > > b. for(i = SIZE; i > 0; i -= STEP) > First, the coding of the loop should have nothing to do with the values > of SIZE and STEP. The code you write should be determined by the > postcondition you wish to establish. Say what? Who cares what the value of i is after the loop? Most of the time I want to see i uninitialized the moment the loop ends (though there are enough exceptions to this rule that I don't want the language to force it on me). > Secondly, the question of errors. If the loop variable reaches a state > from which the postcondition is unreachable, there is an error in the > code. Again, who says there has to be a postcondition? The programmer is thinking about the values i will take on trips through the loop, not about the value it'll have afterwards. ---Dan