From 909b514f46abc54ef404fe9dbd039b8277361676 Mon Sep 17 00:00:00 2001 From: Lyndon White Date: Sun, 14 Apr 2019 11:57:53 +0100 Subject: [PATCH] Replace Val{..} with singleton Ellipsis type --- src/EllipsisNotation.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/EllipsisNotation.jl b/src/EllipsisNotation.jl index 4269e1f..7f8f90a 100644 --- a/src/EllipsisNotation.jl +++ b/src/EllipsisNotation.jl @@ -3,7 +3,9 @@ __precompile__() module EllipsisNotation import Base: to_indices, tail -const .. = Val{:..}() + +struct Ellipsis end +const .. = Ellipsis() @inline fillcolons(inds, I) = fillcolons((), inds, I) @@ -12,7 +14,7 @@ const .. = Val{:..}() @inline fillcolons(colons, t::NTuple{N, <:Any}, ::NTuple{N, <:Any}) where {N} = colons @inline fillcolons(colons, t::Tuple, s::Tuple) = fillcolons((colons..., :), tail(t), s) -@inline function to_indices(A, inds, I::Tuple{Val{:..}, Vararg{Any, N}}) where N +@inline function to_indices(A, inds, I::Tuple{Ellipsis, Vararg{Any, N}}) where N # Align the remaining indices to the tail of the `inds` colons = fillcolons(inds, tail(I)) to_indices(A, inds, (colons..., tail(I)...)) @@ -20,7 +22,7 @@ end # avoid copying if indexing with .. alone, see # https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/issues/214 -@inline Base.getindex(A::AbstractArray, ::Val{:..}) = A +@inline Base.getindex(A::AbstractArray, ::Ellipsis) = A export ..