-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Require case
prefix for patterns in for-comprehension generators
#5511
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
Comments
Using What about |
duplicate of #2578 |
See also https://github.com/oleg-py/better-monadic-for/blob/master/README.md which changes the desugaring to use map and match |
@dwijnand No strong feelings either way in using |
So there's been a lot of proposals related to improving for-comprehensions, but it seems like there's just no one working on Dotty currently who's motivated enough to lead the redesign. To move forward, I suggest people who are interested in the topic build consensus and collaboratively write a SIP. Once we have an accepted SIP, the implementation should be easy. Therefore, I'm going to close this and redirect people to https://contributors.scala-lang.org/t/making-for-simpler-and-more-regular/2160 where the discussion has already started. |
A common beginners' mistake when using
for
-comprehensions is to write a pattern on the left-side of a generator, and to not realize that it desugars tofilter
/withFilter
.I propose that this behavior should be supported only if the patter is prefixed with the keyword
case
, for example,This would be a compile error:
The text was updated successfully, but these errors were encountered: