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

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


Hi Kassen,

I would not go scientific here... :) I just wrote down a line of code 
which I expected to work... However, I've  never written down anything like:

if() {} or while() {}

which I suspect would give a C compiler error.

My point is that the first and the third part of the for() statement can 
be omitted as for now (in ChucK). So I don't see a point why the second 
one shouldn't work the same way.

Regards,
Szilveszter aka Hillaby

Kassen escribió:
>
> Hey Szilveszter!
>
>     (you know, I'm a programmer myself :))
>
>
> You wouldn't say! ;-)
>
>  
>
>     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.
>
> Ok, I see. This makes sense and it makes sense to follow C. I'm going 
> to adopt that trick as well, though for infinite loops that will never 
> break or continue I'll stick to "while(true)" as that's still more 
> readable to me.
>
> So, to be perfectly clear, (as a programmer I like to try and see the 
> structure,) this particular case of a condition is a exception in that 
> it can now be empty, with empty being seen as "not explicitly false 
> and hence true" and this does not hold true for other conditions such 
> as -say- empty clauses in "if" and "while" loops?
>  
> Thanks,
> 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