-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 wildcards from _
to ?
?
#2041
Comments
I wholeheartedly agree that this would be better. I think the main argument against this is cross-compilation support (which is something that we haven't spent enough time thinking about yet I think). Assuming the old syntax is supported under |
However, there is one thing which I think is worth trying to fix: preventing people from writing |
Yes,
Kind projector would not work during this transition (and would not be needed afterwards because the compiler does it natively). There's less need for kind projector in dotty anyway because we have native type lambdas instead of the atrocity involving structural types. But if it's useful one could port a version of kind-projector that uses (say) |
@odersky, as most people will be migrating from Scala 2.12-2.13 to Dotty 1.0\Scala 3.0, @adriaanm, would it be possible to consider adding support for |
I support the direction, but I don't think we can deprecate this in 2.12. We could support the |
If we had The same holds for |
I'd welcome a PR implementing those under |
A discussion about coding convention of higher kinded type declaration: We can change the style documentation right now, to avoid accidentally written |
I very much agree with this proposal, because I've repeated the use of _ for many times, I think reducing the meaning of _ can reduce beginners' confusion. |
Closed in favor of #5379 where the discussion can continue |
Using the underscore for wildcards in types was unfortunate, because it causes a notational discrepancy for types and for values.
C[_]
means an existential:ex(T).C[T]
c(_)
means a universal:x => c(x)
.We'd also like to use some notation for projecting types, but
_
is already taken. So @non's kind projector uses?
instead. But now things get really confusing.F[_]
, but for partial applications it'sF[?]
.?
is the same as Java's wildcard, but Java's wildcard means_
in Scala._
for terms but?
for types.It seems we have everything wrong here and it's no wonder people are confused.
Everything would be so much nicer if we could go back in time and express wildcards with
?
instead of_
._
as a placeholder for type parameters.F[_]
andf(_)
mean the same thing.F[_]
produces a higher-kinded type at definition sites as well as use sites.Changing to dotty might give us the one and only chance to actually achieve that.
_
to?
._
for kind projector's?
.It's still a large step, though. So I am on the fence whether we should do it.
The text was updated successfully, but these errors were encountered: