-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate array of arrays special casing in .= #24095
Conversation
This commit deprecates the special-casing for arrays of arrays when using `A[I...] .=` with entirely scalar indices. Once this deprecation goes away, `A[1] .= 0` will *always* modify the element that is stored at `A[1]`. The outer array `A` will not be modified, regardless of its element type. I have chosen to use the same internal machinery from `@views` for this; when the deprecation is removed the syntactic transform will behave like `broadcast!(identity, @views A[I...], X)`. fixup!
Base.@propagate_inbounds dotview(A::AbstractArray, args...) = view(A, args...) | ||
Base.@propagate_inbounds dotview(A::AbstractArray{<:AbstractArray}, args::Integer...) = getindex(A, args...) | ||
|
||
Base.@propagate_inbounds dotview(args...) = Base.maybeview(args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this dotview
wouldn't be needed and could also be deprecated in favor of maybeview
, right?
(Though it would require changing this line in the parser)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now the two must be uncoupled in order to have the deprecation... and it's probably safest to keep them separate in general.
This commit deprecates the special-casing for arrays of arrays when using `A[I...] .=` with entirely scalar indices. Once this deprecation goes away, `A[1] .= 0` will *always* modify the element that is stored at `A[1]`. The outer array `A` will not be modified, regardless of its element type. I have chosen to use the same internal machinery from `@views` for this; when the deprecation is removed the syntactic transform will behave like `broadcast!(identity, @views A[I...], X)`. fixup!
Should container types now define |
So if implementing the general behavior will also work for broadcasting, then use |
Anyway, this should probably be documented in the manual section on customizing broadcasting for user-defined types... |
This commit deprecates the special-casing for arrays of arrays when using
A[I...] .=
with entirely scalar indices. Once this deprecation goes away,A[1] .= 0
will always modify the element that is stored atA[1]
. The outer arrayA
will not be modified, regardless of its element type. I have chosen to use the same internal machinery from@views
for this; when the deprecation is removed the syntactic transform will behave likebroadcast!(identity, @views A[I...], X)
.Edit: Fixes #20158.