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 match syntax #7610
Change match syntax #7610
Conversation
- A match usually has more than one case anyway - That way, we increase the precedence of `match`, since what follows is always atomic.
`match` is treated like an alphabetic operator, can be appear infix as well as after `.`. Change the `inline` syntax from ``` inline if ... inline s match ... ``` to ``` if inline ... s match inline ... ``` this makes it work better with the new rules for `match`.
The syntax is no longer supported
Better not to mix up to syntax changes in one PR. Also, we might prefer inline match and inline if in the end.
d653012
to
09e5aec
Compare
Best reviewed by looking at changed files directly, since there was a bit of going back of forth on the way. |
Since These are all downstream changes that should be called out as a result of this syntax update Otherwise it would be weird if |
Does this make match redundant with pipe?
…On Sun, Nov 24, 2019 at 7:34 PM Li Haoyi ***@***.***> wrote:
Since match now behaves for all intents and purposes like a method call,
are we going to demote it from a keyword to an intrinsic method the same
way eq, ne, ==, etc. are? Otherwise it would be weird if match was the
only keyword that you could use with or without a preceding .
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7610>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAYAUCMYM2L65AZLL5TR2LQVMMQ5ANCNFSM4JQ3USLA>
.
|
Making |
which IMO is exactly the reason it shouldn't look like a method either. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
case _ => true | ||
} | ||
then "nonempty" | ||
else "empty" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear the selection may break the regularity of Scala syntax. It seems the use case is not important enough to compensate for the loss of regularity.
|
||
```scala | ||
if xsDefined | ||
&& xs.match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that's why they call it "dotty".
match
is now treated like an alphabetic operator, it can be appear infix aswell as after
.
.Motivation given in https://contributors.scala-lang.org/t/pre-sip-demote-match-keyword-to-a-method/2137/36?u=odersky