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
require parens around lambda argument with type annotation #12218
Comments
I wonder how much of corpus would stop compiling with this. Is there any other motivation over "looks similar"? |
You can omit the parens when the lambda is wrapped in a block but not when it's wrapped in parens, you also cannot omit them when the lambda has more than one parameter, so it's a very limited special case. According to Martin it also complicates the parser quite a bit. |
I've made a PR to stop IntelliJ from wanting to remove these parens: JetBrains/intellij-scala#488 |
I fear the body of code that uses this syntax in the wild is far too large (to be precise: nearly all Scala code) – without a scalafix rule at the very least the migration will not be tenable |
note that there is an open proposal to change how self-types are expressed: scala/scala3#7374 |
Self-types look annoyingly like lambdas. Edit: i.e., this is very common case and looks so clean it would be criminal to get rid of it. Just exercising my right to vote. |
I'm just going to chip in and say that if named self types and lambdas are too similar, we can just ban named self types. Un-named self types This similarity also isn't limited to named self types: any named self reference like There are probably 3-4 orders of magnitude more lambdas than there are named self-references out there in the wild; making lambdas more verbose in exchange for preserving the conciseness of named self-references is backwards |
I don't often boo outright, but I noticed this is already encoded ("enshrined"):
Where is @tpolecat our community advocate or liaison or guy we trust, whatever his role, when you really need him? Please don't let them put parens back in. There should be a monitor that ensures that the paren count decreases monotonically. Now I'm going to plant a "Parsers for the People!" sign on the lawn by the curb. Then the HOA will take it down because I don't even have my own lawn to plant a flag. |
@som-snytt I don't feel strongly but I think I would prefer that the number of special cases decrease monotonically. In any case I had never noticed the splendid error message you get when you try to put parens around a self-type.
|
If someone wants to implement a warning for this under |
This happens as a warning under the scala 3 migration scheme. I can't try out the latest And hey, it's quick-fixable! Do I have to edit my excellent SO answer on this parser question? I never saw it as a special case, but a consequence of Scala being a scalable language, in the sense that the scales fall from your eyes.
|
@tpolecat also anything from pre-pandemic qualifies as retro-computing!
oh also, just to show that when the Lord slams one door in your face, etc,
|
{ x: Any => }
looks confusingly like a self-type; write{ (x: Any) => ... }
instead.The text was updated successfully, but these errors were encountered: