# How to modify value of \*scalar\* argument passed to function so that it persists in calling function?

**URL:** https://discourse.julialang.org/t/how-to-modify-value-of-scalar-argument-passed-to-function-so-that-it-persists-in-calling-function/27151
**Category:** New to Julia
**Created:** [August 4, 2019, 4:14pm UTC](https://discourse.julialang.org/t/how-to-modify-value-of-scalar-argument-passed-to-function-so-that-it-persists-in-calling-function/27151 "2019-08-04T16:14:27Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [August 4, 2019, 11:31pm UTC](https://discourse.julialang.org/t/how-to-modify-value-of-scalar-argument-passed-to-function-so-that-it-persists-in-calling-function/27151/9 "2019-08-04T23:31:59Z")

</div>

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](https://en.wikipedia.org/wiki/Evaluation_strategy#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](https://docs.julialang.org/en/v1/manual/performance-tips/index.html#Avoid-changing-the-type-of-a-variable-1) of your object `a`, otherwise that could be another performance trap.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-modify-value-of-scalar-argument-passed-to-function-so-that-it-persists-in-calling-function/27151)._
