just wondered if there is a way to overcome “duplication” in default field names in mutable structs? what do I mean. Assume I have a struct which holds 100 fields,
mutable struct MyStruct param1::Int64 param2::Float64 param3::Any . . . params100
and I wish to initialize it with default values for param1-100.
So if I understood correctly I have to list all parameters and values in three places: the definition, the constructor function default args, and then again inside the new() command, where I also have to list all parameters in the right order of appearance in the definition. So I have three lists of the same parameters in the struct, such as:
mutable struct MyStruct param1::Int64 param2::Float64 param3::Any . . params100 function MyStruct(;param1=1,param2=2.0,... params100="g") return new(param1,param2,...,params100) end
This is a bit tedious for me. Is there a way to shorten this procedure?
Previously I’ve initialized these structs with name-value pairs using args… as input MyStruct(“param1”,10, “param2”,2.0, etc, and then had a parser inside the constructor, which shortened this to only two lists (definition, and defaults). But I want to use the native julia params1=x, param2=y, etc syntax. Is there a way to do so?