Require case prefix for patterns in for-comprehension generators
#5511
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: