Subj : Re: Syntax, style, the infinite monkey theorum and coding To : comp.programming From : Rob Thorpe Date : Mon Aug 22 2005 11:19 am Willem wrote: > Rob wrote: > )> > Ed Prochak wrote: > )> > > how about a C program with a seven page while() loop where the > )> > > condition on the while() loop was seven full lines long (where full > )> > > means about 70characters per line, not counting whitespace)? Sorry I > )> > > don't have the code available. That was at a job nearly twenty years > )> > > ago. It was written by a contractor that the company respected and was > )> > > considered a great programmer. Needless to say I did not share that > )> > > opinion when I was assigned to maintain and debug this beast. > ) > ) Yeah, I've seen code like this that is perfectly understandable. The > ) conditions to break-out of doing something complex can be quite > ) complex. > > Why are you all assuming the seven lines of while-condition are actually > only doing the testing on the conditions ? If it was that nasty, I'm sure > there was some actual work being done in that while-condition as well. > > As a simple example: > > i = 0, j = 10; > do { > if (test(i)) { > something(i, j); > continue; > } > something_else(j); > } while (i = i + 2, j = j * 2, i < N); What I mean is, I've see people do while ((do_quit == 0) && (state_makes_sense > SOMETHING) && (check_baz != 98) .....) That has made sense, even though the programmer could have calculated the single state elsewhere and used that. Certainly there can be really nasty while conditions, that do things using commas, but the fact that a while condition goes on for 7 lines doesn't necessarily mean that it's very nasty. .