Infix sequence wildcard pattern #17900
som-snytt
started this conversation in
Feature Requests
Replies: 0 comments 1 reply
-
Scala 3 post-pandemic:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Scala used to support:
which is "multiarg infix" expression syntax in a pattern context.
Folks would still like to deconstruct variable-length things using infix notation.
One syntactic solution exploits the new sequence wildcard syntax:
The intention is to use
Nil.equals
, but this is not the current semantics even where the wildcard is permitted:From the linked ticket:
Hypothetical syntax:
Currently required verbosity:
The "infix sequence wildcard in binary infix pattern" feature can be considered orthogonal to "non-binary (multiarg) infix pattern":
Accepting
Nil: _*
is an additional feature but necessary for this request to be useful for the common case of extracting one element only. Note that the Scala 2 syntax is not suitable because it introduces a new name:The old syntax error suggests that a special case might be required, since sequence wildcard is not a Simple Pattern.
Transfers scala/bug#12110
Beta Was this translation helpful? Give feedback.
All reactions