# Julian way of writing a constructor

**URL:** <https://discourse.julialang.org/t/julian-way-of-writing-a-constructor/60943>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 11, 2021, 11:50am UTC](https://discourse.julialang.org/t/julian-way-of-writing-a-constructor/60943 "2021-05-11T11:50:15Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [May 11, 2021, 2:18pm UTC](https://discourse.julialang.org/t/julian-way-of-writing-a-constructor/60943/5 "2021-05-11T14:18:12Z")

</div>

As a side note, your `MVectors` are still mutable even if the `State` as a whole is not mutable. Thus, if the scalars do not have to be mutable (or if only a a few of them have), you may better choose to use an immutable struct.

(mutating a scalar in an overall immutable struct requires some strategy of the ones described [here](https://discourse.julialang.org/t/mutable-scalar-in-immutable-object-the-best-alternative/57401))

Also, `Parameters` offers the `@unpack` macro, which can be used with, for example:

```julia
@unpack v_wind, area = s

```

where `s` is of type `State`, in a function that you might be using only these two variables among all those contained in the struct.

---

_[View the full topic](https://discourse.julialang.org/t/julian-way-of-writing-a-constructor/60943)._
