# "Locally global" variable?

**URL:** <https://discourse.julialang.org/t/locally-global-variable/60471>\
**Category:** General Usage\
**Tags:** scope\
**Created:** [May 3, 2021, 4:49pm UTC](https://discourse.julialang.org/t/locally-global-variable/60471 "2021-05-03T16:49:50Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [May 4, 2021, 5:45pm UTC](https://discourse.julialang.org/t/locally-global-variable/60471/21 "2021-05-04T17:45:32Z")

</div>

you can initialize the fields of a mutable struct with immutable items

---

<div class="post-metadata">

**Author:** ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Post date:** [May 4, 2021, 9:39pm UTC](https://discourse.julialang.org/t/locally-global-variable/60471/22 "2021-05-04T21:39:22Z")

</div>

I had in mind something similar to what @Tamas_Papp suggested, and I agree that just splitting the function in a way such that output of one is an argument in the other may be the cleanest way to do this, from a long-term readability point of view.

---

<div class="post-metadata">

**Author:** ![BambOoxX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bambooxx/32/22179_2.png) [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Post date:** [May 5, 2021, 7:28am UTC](https://discourse.julialang.org/t/locally-global-variable/60471/23 "2021-05-05T07:28:52Z")

</div>

Yes, indeed, it just feels weird to initialize my data like this because I don’t have default values for them.  
Some of them are execution parameters (which may be provided with defaults) but others stem from experimental data.  
So if I initialize my mutable struct with something, I must be able to discriminate just initialized and actually loaded data, maybe with an init flag vector ?

```julia
mutable struct MyOverallContainer
    flags::Vector{Bool}
    data1::Data1
    data2::Data2
    result1::Result1
end

```

Where I could modify the `flags` field at each relevant iteration.

[Previous page](https://discourse.julialang.org/t/locally-global-variable/60471.md?page=1)
