Closed
Description
Came up in JuliaDiff/ChainRules.jl#287
I suspect add!!
should take responsiblity as to if it is appropriate to call the InplaceableThunk
's add!
field.
Its fairly easy for us to setup a baseline set of mutable types:
"returns true if `x .= y` will work to mutate `x`"
is_broadcast_mutable{::Array}} = true
is_broadcast_mutable{::SparseVector}} = true
is_broadcast_mutable{::SparseMatrixCSC}} = true
is_broadcast_mutable{::BitArray} = true # probably don't need this one
function is_broadcast_mutable(x::AbastractArray)
p = parent(x)
p === x && return false # did not find a mutable parent
return is_broadcast_mutable(p)
end
is_broadcast_mutable(::Any) = false
ArrayInterface has something like this, but gets it wrong (JuliaArrays/ArrayInterface.jl#77)
and we don't want the dependency
Other types can specialize add!!
themselves; with what ever way they like to be mutated.