Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically infer type based on default #131

Open
mauro3 opened this issue Dec 20, 2020 · 3 comments · May be fixed by #138
Open

Automatically infer type based on default #131

mauro3 opened this issue Dec 20, 2020 · 3 comments · May be fixed by #138

Comments

@mauro3
Copy link
Owner

mauro3 commented Dec 20, 2020

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
@bgroenks96
Copy link

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.

@mauro3 mauro3 linked a pull request Feb 25, 2021 that will close this issue
@mauro3
Copy link
Owner Author

mauro3 commented Feb 25, 2021

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.

@bgroenks96
Copy link

Hi @mauro3 sure, I'll take a look this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants