01-Nov-2013 16:43, John Colvin пишет:
On Friday, 1 November 2013 at 12:37:20 UTC, simendsjo wrote:
2) opSlice
3) alias this

arguably these are the same in the context of the foreach loop. Both
just provide direct access to the underlying array.

No quite. I'd say alias this is frankly a bad idea to provide iteration.
In any case returning naked underlying array is most surely short-sighted.

In short we have 2 ways:
1) Ranges
2) opApply

And a couple of extra things on _top_ of that to keep in mind:
1) Implicit conversion -> hence alias this to a range/opApply type works
2) opSlice is called on foreach aggregate if it's not a range or doesn't have opApply by itself.

--
Dmitry Olshansky

Reply via email to