News for hackers. Stuff that matters.
Re:Philosophy and "for" loops — more from Go and Rust by oofabz on Thursday July 11, 2013 @05:27PM (#6029342)
C also has an empty for loop that works like while (1):

for (;;) {}

Re:Philosophy and "for" loops — more from Go and Rust by mtdewcmu on Friday July 12, 2013 @12:10AM (#6030870)
I think the author is seeing things in C's for loop construct that aren't there. C's syntax is conspicuously clean of unnecessary abstraction. The for construct is just three expressions grouped together for the sake of being convenient. It's not a coroutine. The head of the loop can't be a separate context, or part of the loop's scope: it's not inside the curly braces (which aren't part of the loop, anyway; you can use them anywhere -- loops don't have a scope). The first clause is available to initialize variables, but it's perfectly good style to leave it blank and use an already-initialized variable. It doesn't want to be an anonymous function with its own scope and parameters, because then you couldn't do this:

int c; for(c=0; str[c] != '\0'; c++) {} printf("Length of string = %d\n", c);

C doesn't have a message or a worldview. It's just about saving typing and making common things convenient.

Re:Philosophy and "for" loops — more from Go and Rust by jrarredondo on Thursday July 11, 2013 @05:54PM (#6029506)
My brain always thought that was a no op, but the rule says infinite loop. Why would void be true? Not sure, but there likely was a good reason.
Re:Philosophy and "for" loops — more from Go and Rust by mtdewcmu on Thursday July 11, 2013 @11:20PM (#6030716)
Maybe because true is defined as anything that's not false?
Re:Philosophy and "for" loops — more from Go and Rust by gwu78 on Thursday July 11, 2013 @07:07PM (#6029876)
This is also called an "infinite loop"?

djb uses this a lot.