-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
typedesc[T] can't be used at compile time, unlike generics #8486
Comments
Works with devel template default*[T](t: typedesc[T]): T =
var v: T
v
const a = default(int) |
@yglukhov I know, I'm using devel; it works in your example, but not the example I mentioned above:
|
My bad, sorry. |
Duplicate of #7596. (Please consider grouping related issues together). |
@dom96 how about adding a github label |
Why would it be useful to find duplicated issues? |
=> moved discussion here #8507 |
typedesc[T]
can't be used at compile time, unlike generics, as shown below:Can that limitation be lifted?
NOTE: this affect the debate here: [RFC] guidelines for when to use typedesc vs generics #7517
NOTE: the motivating example was from
default
should be public instead of redefined everywhere; should use default[T] instead of default(T) #8485 ; if this limitation were lifted, we'd be able to usedefault(T)
(orint.default
) at compile time, instead of having to resort todefault[T]()
EDIT /cc @yglukhov NOTE: see workaround below via intermediate
defaultImpl[T]():T
The text was updated successfully, but these errors were encountered: