I seem to recall that this was discussed recently, probably by Matt, but
cannot find it.  I did however find this gist:
https://gist.github.com/alsam/8283205, maybe of help.


On Mon, 2015-09-21 at 06:38, 'Greg Plowman' via julia-users 
<julia-users@googlegroups.com> wrote:
> To further clarify, I thought I could specialise getindex / setindex! on 
> colon 
> type argument.
>
> see below, getindex2 is being called, but getindex is not being called.
> A[:] calls getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at 
> abstractarray.jl:380
> presumably after [:] has been converted to [1:8]
>
>
>
> julia> getindex(A::FArray, ::Colon) = A[start(A) : endof(A)]
> getindex (generic function with 177 methods)
>
> julia> getindex2(A::FArray, ::Colon) = A[start(A) : endof(A)]
> getindex2 (generic function with 1 method)
>
> julia> A = FZeros(Int, -2:8)
> 11-element FArray{Int64,1} (-2:8,)
>
> julia> A[:]
> 8-element Array{Int64,1}:
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>
> julia> @which A[:]
> getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at 
> abstractarray.jl:380
>
> julia> getindex2(A, :)
> 11-element Array{Int64,1}:
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>
> julia>

Reply via email to