Open dlfivefifty opened 4 years ago
Is there any reason this was not done?
Probably just because doing it requires writing good tests, etc., and until someone needs this enough to bite the bullet it's much better to have it error. require_one_based_indexing
was added in the closing days of the Julia 1.0 merge window as a way to protect against more serious bugs.
I see, I'll consider doing a PR when I get the time.
Is there a way to bypass an internal constructor, that is, to make a Diagonal(::OffsetArray)
without wrongly overloading Base.require_one_based_indexing
?
It's in the inner constructor precisely to make that "not possible." (In quotes because of course, it actually is possible, but I ain't tellin' :smile:. Ordinary Julia code should not be calling builtins directly.)
At the moment
Diagonal(::OffsetArray)
is explicitly forbidden:However, supporting it seems to require just 2 changes in Base:
Is there any reason this was not done?
One reason I ask is that the definition
Base.axes(D::Diagonal) = (axes(D.diag,1),axes(D.diag,1))
is helpful for BlockArrays.jl, so thatDiagonal(::BlockArray)
automatically inherits the block structure of the diagonal. I was thinking of making a PR into Base to propose this change but wanted to know context why it wasn't done already.