No subject


Sat Oct 2 15:15:04 UTC 2010


At the meeting on 27th November Julia put
forward an example of highly ambiguous C.
{
for (i = 0; i < 10; stuff(i++));
more_stuff();
}
With the question: how many times is 
more_stuff() executed?
(Answer: once. Note the ; at the end of the for line.)

I pointed out that judicious use of indent
could show up this kind of crap and she asked
me to demonstrate so here it is:
{
  for (i = 0; i < 10; stuff (i++));
  morestuff ();
  for (i = 0; i < 10; stuff (i++))
    morestuff ();
}
I have since thought of another reason to pound
this damn coder's head.
For what values is stuff() executed?
No, not 0-9, it's actually 1-10!

And that's all from your favourite(?)
(re)tired old command-line dinosaur.

Tom





More information about the Kent mailing list