Just a minor comment: this is not a matter of being scalar or not, but of the type being mutable or immutable: mutable structs can be mutated by a function, immutable structs cannot. Julia uses “call by sharing” evaluation strategy, like Python to name one. That’s why above you’ve been suggested to wrap the object in a mutable struct. You’ve been told why boxing your immutable object in a mutable struct is a bad idea for performance. Just make sure that your function f
doesn’t change the type of your object a
, otherwise that could be another performance trap.
How to modify value of *scalar* argument passed to function so that it persists in calling function?
3 Likes