-
Notifications
You must be signed in to change notification settings - Fork 23
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
[RFC] default type parameter for generics #85
Comments
I think your first example should be import typetraits
proc foo6(T:typedesc = typedesc[int]): auto = return T.name
echo foo6(int) #ok
echo foo6(string) # Error: type mismatch: got but expected 'type string'
echo foo6() |
thanks, updated typos and clarified |
It looks like this is working now on devel. Can be closed? |
@bluenote10 The version with typedesc works. The version with generics does not work currently on devel, but in fact it does not even look like valid nim. @zah ? |
@zah thanks for addressing typedesc default params!
well, currently Nim allows this |
Default generic parameters are supported for types. For procs, they might be implemented at some point, but given the current compiler internals that would be a complicated patch, so I don't see this coming soon. More details here: My recommendation is to stick with |
Why should this be supported? What is a use case that warrants this feature? |
However, given all the recent improvements to
After that we can finally start profiting:
|
I don't think we should rush too much here and close valid issues as wontfix just because fixing them will take longer/might be difficult. |
This RFC is stale because it has been open for 1095 days with no activity. Contribute a fix or comment on the issue, or it will be closed in 7 days. |
These should be supported IMO:
with typedesc (EDIT this one now works)
with generics
links
mentioned here: nim-lang/Nim#3502 (comment)
The text was updated successfully, but these errors were encountered: