I have one scenario that happens all the time. I get a vector of vectors and I need to obtain each component individually to perform some analyses and plot the data. Today, I do:
If I had to pick, I’d pick the former because it’s strange to think of a dotted instance as something that is iterated. I would prefer neither because it’s simpler to understand if we always dot the callable.
TLDR: there are three conflicting meanings to what A.[I, J] could possibly mean:
You are implicitly assuming A is a collection of arrays and you want to perform the same indexing operation over all of them (this would be getindex.(A, (I,), (J,)))
You are implicitly assuming A is a single array and you want to broadcast over the passed indices — great for fusing these accesses or doing “diagonal” indexing (this would be getindex.((A,), I, J))
Or you (probably don’t) want both the array and the indices to participate in the broadcast simultaneously (this would be getindex.(A, I, J))
I get it, but like… does anyone look at that and not expect the second one? I understand you could interpret other ways, but assuming A is an array of arrays in the first and last case seems IMO contrarian and not really the way most people would read that syntax. Maybe someone will say differently, but I haven’t seen someone outside of that thread assume it would or could mean anything but getindex.((A,), I, J) like OP says. This is really a case of “perfect is the enemy of good” in my view.
Wrt developing multi indices access, as in getindex.(Ref(x), is), further: also consider a more principled approach of GitHub - andyferris/Indexing.jl: Generalized indexing for Julia. There Y = getindices(X, I) always implies that Y has the same indices as I with values of X:
getindices(container, indices)
Return an indexable container with indices `keys(indices)` and values `container[i]` for
`i ∈ values(indices)`. This generalizes scalar `getindex(container, index)` for multiple
indices, for dictionaries, tuples, named tuples, etc.