From 42fc75d5f5273db041c1302beceaf7b892f49e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 15 Oct 2024 16:19:04 +0200 Subject: [PATCH] Add comments --- src/dispatch.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dispatch.jl b/src/dispatch.jl index 10dbc6d..1db2dac 100644 --- a/src/dispatch.jl +++ b/src/dispatch.jl @@ -15,10 +15,13 @@ abstract type AbstractMutable end function Base.sum( a::AbstractArray{T}; - dims = missing, + dims = :, init = zero(promote_operation(+, T, T)), ) where {T<:AbstractMutable} if !ismissing(dims) + # We cannot use `mapreduce` with `add!!` instead of `Base.add_mul` like + # `operate(sum, ...)` because the same instance given at `init` is used + # at several places. return mapreduce(identity, Base.add_sum, a; dims, init) end return operate(sum, a; init)