Re: feature request : for
- Posted by DerekParnell (admin) Oct 15, 2012
- 1119 views
Kat said...
Please elaborate your points to show me why adding "each" is a good idea.
It is not so much that "each" is a good idea per se, but more that the form ...
for X = A do
and
for X = A to B do
are visually similar and the reader of the code won't see the difference until reaching the to keyword. Whereas using a qualifier next to the for keyword quickly signals a special case of the for to the code reader.
and
for X = A to B do
I was thinking that the 'each' qualifier would simply be syntax sugar ...
for each char in txtline do if char .... end for -- The above construct would be equivalent to ... for i = 1 to length(X) do object char char = X[i] if char ... end for
To me, the 'each' idea does roll off the tongue quite well. May its a difference in how we view the world.
I'm not sure why you think that continue or the by phrase would not be possible with the each idea.
for each char in txtline do if char = WHATEVER then continue end if ... end for Y = 0 stuff = {1,3,6,9,12,25,39} for each X in stuff by 2 do Y += X end for ? Y --> 58