English is not my first language, but since the keywords in programming languages are English words, I usually find it easy to read source code as English sentences:
if (x > 10) f();
=> "If variablex
is greater than10
, then call functionf
."while (i < 10) ++i;
=> "While variablei
is less than10
, increasei
by1
."
But how a for
loop is supposed to be read?
for (i = 0; i < 10; ++i) f(i);
=> ???
I mean, I know what a for
loop is and how it works. My problem is only that I don't know what the English word "for" exactly means in for
loops.
for each
. So it would becomefor each i, till i is less than 10, perform the following steps
.for each i
pretty much explains everything.