"Locally global" variable?

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

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.

1 Like

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 ?

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

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