-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow getindex(::MyType, ::Colon)
to be customized
#9419
Comments
This is something that needs to be changed in the parser, and is part of #9150. Re the |
👍 |
I have a branch that already does this, has @andreasnoack not included it in #9150? |
Yes. It is part of #9150 which I'll hopefully will finalize between Christmas and the end of the year. |
Oh I had seen #9150 before posting, but didn't understand it did hat I wanted, good! |
And similarly for
setindex!
.For example:
This is worse if
endof(::A)
is defined, as thenA()[:]
chooses silently the unintendedgetindex
method.If allowing customization of
Base.getindex(a::A, ::Colon)
does not happen, I would request thata[:]
is translated toa[beginof(a):endof(a)]
, as some indexable collections have an indice starting at something else than 1.At the very least, the doc for
getindex/setindex!
should mention this special case, where "The syntaxa[i,j,...]
is converted by the compiler togetindex(a, i, j, ...)
" does not seem true.Also, in "base/subarray.jl", this method is defined:
getindex{T}(v::AbstractArray{T,1}, ::Colon) = v
, should it be removed or is it used?The text was updated successfully, but these errors were encountered: