On Monday, August 17, 2015 at 1:03:17 PM UTC-4, Sisyphuss wrote:
I read the "
interfaces" chapter of the documentation today. I learned that, if you define an iterable as a subtype of AbstractArray, with only defining three methods (including `size()`, excluding `start()`), you can iterate on it just like iterate on an normal Array.
Iteration should work just fine in 0.4 if OffsetArray defines its own `eachindex` method.
Although more and more for loops are written generically using `eachindex`, there are still a lot of methods that use the old linear indexing standby:
for i=1:length(A)
@inbounds A[i] = …
end
This is where things get really hairy for OffsetArrays. That `@inbounds` propagates through to the inner array assignment, which will lead to silent data corruption and/or segfaults. That's really why it shouldn't be an AbstractArray.