[chuck-dev] for loop, empty conditional statement, possible fix

Szilveszter Tóth silvestre.toth at gmail.com
Fri Oct 23 09:20:52 EDT 2009

Hi, Kassen,

I noticed this bug when I wrote about 20 lines of code in a row, (you 
know, I'm a programmer myself :)) and then I tried to run it, which 
caused ChucK to crash.
I had to undo the changes step-by-step until ChucK worked again.

I'm a C programmer, and in C, I often write an infinite loop like this: 
for(;;) {}

I prefer for() loops to while() loops, because for loops have the 
ability to step the cycle variable even if you put a continue; in them.

And programmers have the ability to forget to step variables in a 
while() loop. :)

Szilveszter aka Hillaby

Kassen escribió:
> Hi Szilveszter,
>     I also checked out the source code and made a change which made
>     this loop work:
>     at chuck_dev\v2\chuck_type.cpp:873:
>     I enclosed the switch() block in a conditional:
>     if (stmt->c2) { ... }
>     Now it seems to work.
> First; great job on fixing this crash, that's the spirit!
> I do have a question though. It seems that you are implying here that 
> a empty condition now evaluates to true (or at least not false). 
> Assuming we adopt this fix; would this now be true in the general 
> case, or just for "for" loops? Are there precedents on empty 
> conditions evaluating to true?  Just curious; crash prevention is the 
> main thing here, I don't see much practical use in empty "for" loops 
> anyway, because "while(1)" is just as one character more than 
> "for(;;)" and a lot more readable.
> Yours,
> Kas.
> ------------------------------------------------------------------------
> _______________________________________________
> chuck-dev mailing list
> chuck-dev at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev

More information about the chuck-dev mailing list