mauro3/Parameters.jl

Default not working?

rveltz opened this issue · 2 comments

Hi,

I expected this would work...
Can you explain why it does not please?

@with_kw struct A{T}
           a::T  = 1.0
           end
 @with_kw struct B{T,E}
           a::E  = A{T}() 
           end
B()

whereas A() works.

Thank you for your very helpful package,

It cannot know what T is. Your case only works when the type-paras are fully specified:

julia> B{Int,A{Int}}()
B{Int64,A{Int64}}
  a: A{Int64}

I think you want:

julia> @with_kw struct BB{E}
                  a::E  = A() 
                  end
BB

julia> BB()
BB{A{Float64}}
  a: A{Float64}

Does that help?

I see....

Thank you!