Description
As @timholy pointed out in #35839, the meaning of init
in in-place multi-dimensional reducers like sum!
and count!
are incompatible with reduce
etc.
Now that sum(...; init)
#36188 is merged and would be shipped with Julia 1.6, it's a bit concerning that init
in sum!(r, A; init = false)
and sum(A; init = false)
means something completely different. I think it might make sense to deprecate or "soft-deprecate" init
for sum!
etc. By "soft-deprecate" I mean to add a new keyword argument that has init
as the fallback without depwarn
. This new keyword argument would be documented as a preferred way to control the initialization of the destination array. Since sum!
etc. do not actually document init
, going directly to deprecation might be OK. But, since this keyword argument exists for a long time, I'm inclined to treat this as a fully-fledged public API. (This is a bit tricky case because it's unclear if performance-breaking but semantics-preserving change should be treated as non-breaking.)
For the actual name of the new keyword argument, how about sum!(r, A; fill = true)
instead of sum!(r, A; init = true)
?