# Best practice for storing, passing, and managing parameters in economic models

**URL:** <https://discourse.julialang.org/t/best-practice-for-storing-passing-and-managing-parameters-in-economic-models/64705>\
**Category:** Finance and Economics\
**Tags:** performance\
**Created:** [July 15, 2021, 4:52pm UTC](https://discourse.julialang.org/t/best-practice-for-storing-passing-and-managing-parameters-in-economic-models/64705 "2021-07-15T16:52:37Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [July 16, 2021, 8:47pm UTC](https://discourse.julialang.org/t/best-practice-for-storing-passing-and-managing-parameters-in-economic-models/64705/11 "2021-07-16T20:47:41Z")

</div>

Probably you meant:

```julia
@with_kw struct Params
  x::Vector{Float64} = [0.5]
end

```

I agree that having _one_ value in an immutable struct that must be mutable lacks a beautiful syntax. I have even asked that here before: [Mutable scalar in immutable object: the best alternative?](https://discourse.julialang.org/t/mutable-scalar-in-immutable-object-the-best-alternative/57401)

In the cases I needed that I finally keep using a vector with a single element.

None of the alternatives is completely clean, IMO. To have a clean syntax use a mutable struct,

```julia
julia> @with_kw mutable struct Params
         α::Float64 = 1.0
       end
Params

julia> a = Params()
Params
  α: Float64 1.0

julia> a.α = 2.0
2.0

julia> a
Params
  α: Float64 2.0

```

But that may have its performance penalties.

(now I see that a great part of this was already mentioned before)

---

_[View the full topic](https://discourse.julialang.org/t/best-practice-for-storing-passing-and-managing-parameters-in-economic-models/64705)._
