checkbounds return value #13334
Labels
docs
This change adds or pertains to documentation
error handling
Handling of exceptions by Julia or the user
help wanted
Indicates that a maintainer wants help on an issue or pull request
I was a bit surprised to notice that the function
checkbounds(A::AbstractArray{T,N}, I...)
returnstrue
if it does not throw aBoundsError
.I would have expected it to return
nothing
, especially since the documentation makes no mention of return value:Note that there is another version of
checkbounds
that is explicitly asked to return aBool
:Two possible solutions:
checkbounds(A::AbstractArray{T,N}, I...)
to returnnothing
if it does not throw an error. This will involve going through existing packages to make sure nobody is relying on the current behavior.true
is actually no accident, and modify the documentation to mention the return value. If this decision is taken, it's especially important to make this explicit in the documentation, as subtypes ofAbstractArray
will want to also have theircheckbounds
returntrue
to be consistent with the original interface (otherwise there can be subtle breakage).My vote is for the first option, as returning
true
is redundant if no error is thrown.The text was updated successfully, but these errors were encountered: