Boxing is merely one of the uses, see the examples in the readme. Two of the three types, the ones whose names currently start with Box*
prefix, box their only element, due to being defined with mutable struct
. In contrast, the third type, ZeroDimArray
, is defined with struct
, not with mutable struct
, so it doesn’t do boxing.
Will try to make this more clear in the readme again.
A name such as BoxedVals.jl
would only cover two of the three exported types, as just explained.
For performance mostly:
- Use
ZeroDimArray
to avoid the overhead of amutable struct
, when amutable struct
is not required. - Use
BoxConst
(that’s the current name at least) to:- forbid mutation
- reap the benefits from letting the compiler know there can’t be any mutation, such as better inferred effects, to enable constant folding
Will try to add something to that effect to the readme, or make it more clear.
Just addressed this immediately above.
Sometimes one just needs a reference to accomplish the goal, that is, access performance is not the only important thing. I’ll quote @foobar_lv2 from two days ago:
It’s possible I haven’t ever written code like that, but the idea is, if it’s not clear, that there’s some data structure one wants to implement, one needs references to implement this data structure, and either:
- needs to forbid mutation for safety
- wants to let the compiler know there’s no mutation to enable the compiler optimizer more
Will also try to explain this better in the readme, however I’m afraid it’s becoming too big, possibly causing some to avoid reading it. It’s possibly already bigger than the source code. Perhaps it just needs better structure?