@@ -30,13 +30,17 @@ macro !(expr)
3030 if Meta. isexpr (x, :call )
3131 isdotoperator (x. args[1 ]) && return x
3232 return Expr (:call , Expr (:call , _maybb, x. args[1 ]), x. args[2 : end ]. .. )
33- elseif Meta . isexpr (x, :. = ) && x. args[1 ] isa Symbol
33+ elseif isdotoperator (x . head) && isequalsoperator (x . head ) && x. args[1 ] isa Symbol
3434 @assert length (x. args) == 2
3535 lhs, rhs = x. args
36- return :($ lhs = $ materialize!! (
37- $ Base. @isdefined ($ lhs) ? $ lhs : $ (Undefined ()),
38- $ air .($ rhs),
39- ))
36+ op = unequalsoperator (undotoperator (x. head))
37+ if isnothing (op)
38+ return :($ lhs = $ materialize!! (
39+ $ Base. @isdefined ($ lhs) ? $ lhs : $ (Undefined ()),
40+ $ rhs,
41+ ))
42+ end
43+ return :($ lhs = $ (Extras. broadcast_inplace!!)($ op, $ lhs, $ rhs))
4044 end
4145 return x
4246 end |> esc
@@ -47,13 +51,23 @@ foldexpr(f, ex::Expr) = f(Expr(ex.head, foldexpr.(f, ex.args)...))
4751
4852isdotoperator (x:: Symbol ) = undotoperator (x) != = nothing
4953
54+ isequalsoperator (x:: Symbol ) = unequalsoperator (x) != = nothing
55+
5056function undotoperator (x:: Symbol )
5157 startswith (string (x), " ." ) || return nothing
5258 op = Symbol (string (x)[2 : end ])
5359 Base. isoperator (op) || return nothing
5460 return op
5561end
5662
63+ function unequalsoperator (x:: Symbol )
64+ endswith (string (x), " =" ) || return nothing
65+ op = Symbol (string (x)[1 : end - 1 ])
66+ Base. isoperator (op) || return nothing
67+ return op
68+ end
69+
70+ # Should not be required anymore. Keep for backwards compatibility?
5771function air end
5872struct Aired{T}
5973 value:: T
0 commit comments