On Wednesday, 7 February 2018 at 01:45:27 UTC, Jonathan M Davis
wrote:
Perhaps, but foreach does not support that.
foreach(e; range)
{
...
}
is lowered to something like
for(auto __range = range; !__range.empty; __range.popFront())
{
auto e = __range.front;
...
}
Fun fact: an actual lowering from the compiler:
Result __r39 = iota(2).opSlice();
for (; !__r39.empty(); __r39.popFront())
{
int a = __r39.front();
}
https://run.dlang.io/is/QihjQi
(sorry for being slightly off-topic, but it's always interesting
for me to check whether our assumptions for of the inner-workings
of the compiler are true ...)