* Sean 'Shaleh' Perry <[EMAIL PROTECTED]> [May 18. 2002 11:52]:
> oh well, I tried replacing one of Brad's while loops[1] with a for loop and
> forgot about why I left the while loop in the first place.
> 
> while (1) {
>   it = find(tmp, end, ',')
>   addWorkspaceName(string(tmp, it))
>   if (it == end) break;
>   ++it;
> }
> 
> just screams to be a for loop does it not?  However the catch is the order of
> the last two calls.  It checks the value THEN increments.  So what was
> happening was we read the last workspace name and it pointed to the end of the
> string and the the for loop incremented it so it was now end + 1 and undefined.
>  Ooops.  Hence the crash, the loop condition was never met.  I reverted the
> change and actually tested the code this time.
> 
> I am usually better about seeing the binary work before I hit commit but I
> thought I had not changed anything drastic enough to matter.
> 
> [1] seems one of Brad's coworkers believes that a for() loop has no place in C
> and a while loop should always be used.  I obviously disagree (-:

Well, the compiler converts the for-loop to a while anyway :-)

-- 
Mads Martin J�rgensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogic, with just a little bit more effort?"
                                -- A. P. J.

Reply via email to