Threaded for loop over arbitrary indexable objects

Currently the following code fails:

julia> Threads.@threads for c in "ssf"
       end

Error thrown in threaded loop on thread 0: MethodError(f=typeof(Base.unsafe_getindex)(), args=("ssf", 1), world=0x000000000000643a)

(the original problem was posted in DataFrames.jl here)

The reason is that Base.unsafe_getindex is used internally and it is defined only for a limited number of collection types.

With Julia 1.3 I expect that threads will be used more often.

So my question is if it is intentional and required to be restricted or could be allowed for a wider range of types that support getindex (as I suppose it could)?

EDIT: the example given above is probably not best, as strings are not indexable with step 1, but see the linked DataFrames.jl example where GroupedDataFrame is properly indexable with 1-increment, but on purpose we do not make it a subtype of AbstractArray.

EDIT2: probably the simplest example is with a Tuple:

julia> @Threads.threads for i in (1,2,3)
       end

Error thrown in threaded loop on thread 0: MethodError(f=typeof(Base.unsafe_getindex)(), args=((1, 2, 3), 1), world=0x00000000000063fd)
3 Likes