
On Thursday 2005-09-22 20:00, Josiah Carlson wrote: [Alexander Myodov:]
But for the "performance-oriented/human-friendliness" factor, Python is anyway not a rival to C and similar lowlevellers. C has pseudo-namespaces, though.
C does not have pseudo-namespaces or variable encapsulation in for loops.
Ah hah hah! Look ladies and gentlemen, I caught myself a troll! Python does not rival C in the performance/friendliness realm? Who are you trying to kid?
I think you've misunderstood Alex here; he's saying that Python and C don't occupy the same region of the spectrum that runs from "high performance, human-unfriendly" to "lower performance, human friendly". Which is correct, unlike some other things he's said :-).
"for (int i = 0; i < 10; i++)" works fine nowadays.
I'm sorry, but you are wrong. The C99 spec states that you must define the type of i before using it in the loop. Maybe you are thinking of C++, which allows such things.
No, Alex is right on this one too. Maybe you are thinking of C89, which forbids such things. 6.8.5.3 The for statement [#1] Except for the behavior of a continue statement in the loop body, the statement for ( clause-1 ; expr-2 ; expr-3 ) statement and the sequence of statements { clause-1 ; while ( expr-2 ) { statement expr-3 ; } } are equivalent (where clause-1 can be an expression or a declaration).123) ... 123Thus, clause-1 specifies initialization for the loop, possibly declaring one or more variables for use in the loop; expr-2, the controlling expression, specifies an evaluation made before each iteration, such that execution of the loop continues until the expression compares equal to 0; expr-3 specifies an operation (such as incrementing) that is performed after each iteration. If clause-1 is a declaration, then the scope of any variable it declares is the remainder of the declaration and the entire loop, including the other two expressions. (This is from a late draft of the C99 spec; I'm fairly sure the final version is no different.) -- g