bug me now / bug me later

brnstnd at kramden.acf.nyu.edu brnstnd at kramden.acf.nyu.edu
Thu Jun 14 15:22:10 AEST 1990


In article <7498 at fy.sei.cmu.edu> firth at sei.cmu.edu (Robert Firth) writes:
> In article <811 at sagpd1.UUCP> jharkins at 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



More information about the Comp.lang.c mailing list