MaybeInplace.jl

Rewrite Inplace Operations to be OOP if needed
Author SciML
Popularity
6 Stars
Updated Last
3 Months Ago
Started In
November 2023

MaybeInplace

Join the chat at https://julialang.zulipchat.com #sciml-bridged

CI codecov Package Downloads Aqua QA

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style

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.

Installation

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

How This Works?

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