Automatically infer type based on default
mauro3 opened this issue · 3 comments
Something like this could be useful:
@with_kw struct A
a::typeof = 1:0.4:7
end
instead of a::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}
or a::typeof(1:0.4:7)
.
Could be added to @deftype
as well
@with_kw struct A @deftype_typeof
a = 1:0.4:7
b = 7.0
c = "a"
end
Yes, please! Any idea how much time this would take? I have a use-case where I would have to duplicate the type information in both the field type and the value, so I would really like to have this feature to avoid this :)
If it's doable in a few hours, I don't mind taking a crack at it.
Hi Brian! Thanks for the offer of help. Whilst I tried to look up where to make the changes, I just ended up doing the change myself, see PR #138. However, that PR still needs testing, tests and docs. If you could provide those, that certainly would help.
Hi @mauro3 sure, I'll take a look this weekend.