MaybeInplace.jl does a simple thing: If you write a code for mutable arrays, that won't work for immutable arrays. This package provides a macro @bb
or @bangbang
that will automatically convert the code to make it work for immutable arrays as well.
MaybeInplace is a Julia Language package. To install MaybeInplace, please open Julia's interactive session (known as REPL) and press ] key in the REPL to use the package mode, then type the following command
pkg> add MaybeInplace
The code is simple enough to be self-explanatory. The basic idea is as follows, if you have the following code:
@bb @. x = y + z
This macro will convert it to:
if setindex_trait(x) === CanSetindex()
@. x = y + z
else
x = @. y + z
end