You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new rewrite #170 adds support for sum(generator; init), but it doesn't add support for the two-argument sum(f, x). I think automatically rewriting that gets a little risky, because we don't know that:
sum(f, x; init) ===sum(f(x) for a in x; init = init)
(It might depend on the types, although it'd be pretty poor form to change the semantics of sum like that.)
I also don't see how we would use functions instead of the loop, because in the functional case we wouldn't be able to rewrite in-place?
Using for loops for generators may create type instabilities, see https://discourse.julialang.org/t/multiplying-by-a-variable-in-a-constraint-causing-type-instability-in-code-warntype/32239 and forces us to create local scopes with
let
in the macro.We could switch to a functional approach similarly to jump-dev/JuMP.jl#2070
Moreover, we currently we rewrite
sum(... for i in ...
but we don't rewritesum(i -> ..., ...)
.The text was updated successfully, but these errors were encountered: