diff --git a/base/abstractarray.jl b/base/abstractarray.jl index adc104dadb90b..0defd8fe3c128 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -606,6 +606,16 @@ end size_to_strides(s, d) = (s,) size_to_strides(s) = () +""" + isstored(A::AbstractArray, inds...)::Bool + +This is a function for testing if the array `A` stores an actual value at the index specified by `inds`, +i.e. if `A[inds...]` will look up a value from some storage, or if it gives some computed fallback value. + +A result of `true` does *not* guarantee that there is truly a stored value at that index since the default +implementation of this function simply returns `true` unconditionally (or errors if out of bounds). However, +a result of `false` *is* a guarantee that there is no stored value at that index. +""" function isstored(A::AbstractArray{<:Any,N}, I::Vararg{Integer,N}) where {N} @boundscheck checkbounds(A, I...) return true diff --git a/base/public.jl b/base/public.jl index bc3d76e86eadc..0db4005d61989 100644 --- a/base/public.jl +++ b/base/public.jl @@ -34,6 +34,7 @@ public # arrays has_offset_axes, require_one_based_indexing, + isstored, # collections IteratorEltype,