what was the reason for foreach(x; y; z)?
To support iterators, and support looping over both indices and values in one operation.
why is it not possible to have the parser distinguish foreach(x, y) from foreach(x, y, z)?
It is, but the semantics get strange, since y in the first case is a value, but in the second is an index.
The difference in syntax also helps detecting bugs. cf:
foreach(x,y) foreach(x,y,) foreach(x,,y)
/ Henrik Grubbström (Lysator)
Previous text:
2004-09-26 21:23: Subject: foreach(x, y) vs foreach(x; y; z)
hi,
what was the reason for foreach(x; y; z)? why is it not possible to have the parser distinguish foreach(x, y) from foreach(x, y, z)? i remember reading that there is a backwards compatibility problem, but i don't see where this would be.
greetings, martin.
/ Brevbäraren