Roger-luo / Configurations.jl

Options & Configurations made easy.
https://configurations.rogerluo.dev/stable
MIT License
80 stars 12 forks source link

`to_dict` does not contain default values #6

Closed rejuvyesh closed 3 years ago

rejuvyesh commented 3 years ago

As the title says:


julia> @option mutable struct OptA; a::Int=1; end

julia> @option mutable struct OptB; b::OptA=OptA(); end

julia> opt = OptB();

julia> to_dict(opt)
OrderedCollections.OrderedDict{String,Any}()

Because of this reason, there is no easy way to just dump the default values for a config.

Roger-luo commented 3 years ago

Hi this is intentional, I don't see any use case that requires the default value to exists in the configuration file/dict, leaving a field empty means using the default value already.

If you want to do the reflection of default values, consider field_defaults or field_default function for default value reflection.

Roger-luo commented 3 years ago

I‘m closing this, feel free to open other issues if this is still a problem.