On Wednesday, 14 June 2017 at 19:22:24 UTC, Steven Schveighoffer wrote:
For example:

foreach(i, v; hashmap) => i is counter, v is value

Later hashmap adds support for iterating key and value. Now i is key, v is value. Code means something completely different.

If we take a step back, I think we are discussing the generalization of foreach. Let's assume we want to preserve the current foreach behavior where associative types iterate with key and value pairs. If the "hashmap" in your example was supposed to be an associative type then `i` wasn't a counter, it was the key already. If "hashmap" didn't define the iteration key (using a new kind of opApply or whatever) then it wasn't an associative type, and therefore your change wouldn't be valid.

So, we just have to be careful that when foreach(i, v; foo) is introduced the relevant types in phobos also implement the new behavior, so that this situation doesn't arise afterwards..

Reply via email to