Change wildcards from `_` to `?` ?
See original GitHub issueUsing the underscore for wildcards in types was unfortunate, because it causes a notational discrepancy for types and for values.
- For types,
C[_]
means an existential:ex(T).C[T]
- For values,
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.
- For higher kinded definitions, you write
F[_]
, but for partial applications it’sF[?]
. ?
is the same as Java’s wildcard, but Java’s wildcard means_
in Scala.- Function placeholders are written
_
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 _
.
- We could then use
_
as a placeholder for type parameters. - This would make
F[_]
andf(_)
mean the same thing. - It also means that
F[_]
produces a higher-kinded type at definition sites as well as use sites. - The wildcard notation would be aligned with Java
Changing to dotty might give us the one and only chance to actually achieve that.
- We have a rewrite tool that could automatically rewrite all wildcard occurrences of
_
to?
. - We could at the same time do the opposite rewrite to
_
for kind projector’s?
.
It’s still a large step, though. So I am on the fence whether we should do it.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:68
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How to Find and Replace in Word (and Use Wildcards)
Position the cursor at the location in the document where you want to start finding and replacing. · Click the Home tab in...
Read more >Finding and replacing characters using wildcards
To begin, you must first turn Wildcards on in the Find/Replace dialog. To do so, bring up the Find dialog, click More and...
Read more >How to Use Wildcards in Word - CustomGuide
1. Click the Find list arrow. 2. Select Advanced Find. 3. Click the More button.
Read more >Replace using wildcards - Graham Mayor
Wildcard searches are case sensitive. ... Start by identifying the string you wish to replace and then pop up the replace function (CTRL+H)...
Read more >How to use Wildcards to do Advanced Find and Replace in ...
Using Wildcards to Find and Replace in Microsoft Word · Choose the wildcard character · Type additional text in the Find box ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
However, there is one thing which I think is worth trying to fix: preventing people from writing
foo[M[_] <: List[_]]
when they meantfoo[M[X] <: List[X]]
, I opened an issue for that some times ago: https://github.com/lampepfl/dotty/issues/1809If we had
?
under an -Xfuture flag we could deprecate_
and rewrite in the first version of dotty, which would speed up the conversion.The same holds for
with
-->&
. If we could get&
under-Xfuture
we could deprecate and rewrite immediately in dotty.