[clue-tech] increment weather

Jed S. Baer cluemail at jbaer.cotse.net
Tue Feb 23 19:15:08 MST 2010


On Tue, 23 Feb 2010 14:29:59 +0000 (UTC)
dennisjperkins at comcast.net wrote:

> But even on Dennis's form (or Jed's while loop, which is essentially
> the same) I wonder whether in-loop mods are a good idea. Remember what
> Kernighan said about debugging being harder than coding...

Well, I kinda think the whole point of the while loop is that the loop
condition variable _is_ modified inside the loop. The fact that you're
incrementing it, possibly in a conditional manner, and using it as a
counter is ... uh, not important, as far as correctness goes (JHMO, but
then I never cared all that much about correctness, only results).

Well, I suppose I care about correctness some. As in I wouldn't use:

  for (( i = 0; i < 10; i++ ))

if I were going to be messing with i in the loop. Partly because I expect
an optimizer (though obviously not in bash, I think) to use a register
for a counter, which might not work if i is modified inside the loop. Or
maybe not, just a thought.

jed
-- 
Ok, so we should be thinking of a lovable, cuddly, stuffed penguin
sitting down after having gorged itself on herring. Still with me? 
 -- Linus Torvalds


More information about the clue-tech mailing list