I imagine this will be possible some day, but I can't predict when.
Currently, if your slices are contiguous (step size 1 in each range), there is
in fact another option: encode the slice with a CartesianRange. See
http://julialang.org/blog/2016/02/iteration/
Example:
julia> function foo(A, R)
s = zero(eltype(A))
for I in R
s += A[I]
end
s
end
foo (generic function with 1 method)
julia> function bar(A)
s = zero(eltype(A))
for j = 1:size(A,2)
s += foo(A, CartesianRange(CartesianIndex((1,j)),
CartesianIndex((size(A,1),j))))
end
s
end
bar (generic function with 1 method)
julia> A = rand(4,10^4);
julia> bar(A)
20026.547698847495
julia> @time 1
0.000008 seconds (148 allocations: 10.151 KB)
1
julia> @time bar
0.000001 seconds (3 allocations: 144 bytes)
bar (generic function with 1 method)
Look ma, no allocation!
--Tim