-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
change x^p for literal p from x^Val{p} to x^Val{p}() #20783
Conversation
(Will have to be rebased after #20782 is merged.) |
I don't think it's especially important for |
with this change is it possible to remove the |
Okay, then I will close this PR. At some point in the future, maybe there will be a general overhaul of this. |
@musm, I think it is already possible to remove the
|
Even better: wouldn't |
@StefanKarpinski, if you actually want to dispatch on a value, it doesn't seem like compiler optimizations will help? |
Yes, but we already have these things called function names. It turns out you can even include practically arbitrary strings in them! And it's even way shorter to type Yes, the |
It's possible that the dispatch table for |
Well, there is the case of wanting to dispatch differently for |
The docs (src/manual/types.md) currently say:
If this has changed to the opposite, updating the docs would be good. |
I said it would be nicer, i.e. objecting to the current state. It has not changed. If we changed it, we'd update the docs. |
This changes #20530 to use
Val{p}()
rather thanVal{p}
, so that we dispatch on^{p}(x, ::Val{p})
rather than^{p}(x, ::Type{Val{p}})
.This change was suggested by @vtjnash in #19890 because the old behavior thwarts constant folding. With
Val{p}()
, constant-folding works again: