Description
Hi,
The macro @!
always returns an expression with a leading :($(esc(C)) =
.
Using the README multiplication example, what are the use-cases for returning C = mul!(C,A,B)
instead of only mul!(C,A,B)
?
It renders the macro incompatible with a struct field result.
struct myStruct
C
end
S = myStruct(rand(10))
A = rand(10,10)
B = rand(10)
@! S.C = A * B # the macro would return S.C = mul!(S.C, A, B) but throws an error
As is, the macro throws an error because :(S.C)
is not a Symbol
. Without this test, it later throws the error immutable struct of type myStruct cannot be changed
because of the leading S.C =
that would mutate the field. However, mul!(S.C, A, B)
works fine because it modifies S.C
in-place.
It is common to use functors for in-place operations in linear algebra (see ArnoldiMethod.jl example) but @!
is incompatible as is.
I forked this repo and implemented a @!
compatible with in-place operations on struct fields. I relaxed the test on :C
to Union{Symbol, Expr}
and removed the leading :($(esc(C)) =
that the macro returns.
I am curious to hear your opinion. Thanks.
Activity