-
Notifications
You must be signed in to change notification settings - Fork 14
Deprecate method value (foo _
) syntax?
#273
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
For 0 argument the only alternative is |
True, but I think the benefit of
outweighs having to explicitly eta-expand for the 0-ary case. |
this is being taken up at scala/scala3#2570
|
@adriaanm Or stop parenthesis injection for nullary functions. |
Dotty's doing that, but I don't think we can make everyone insert the needed |
foo _
) syntax?foo _
) syntax?
Carried over from #489: Currently, http://www.scala-lang.org/files/archive/spec/2.12/06-expressions.html#method-values says:
Since we've removed eta-expansion for nullary methods, for consistency we should also deprecate and drop the last part re: "parameterless method or call-by-name parameter". Those will need to be written explicitly using Eventually (ideally), all method references will be eta-expanded regardless of expected type, and method value syntax will be dropped since it's redundant. |
this is happening in Dotty eventually, but out of scope for Scala 2 |
Uh oh!
There was an error while loading. Please reload this page.
the difference between
foo _
andfoo(_)
(orfoo(_, _)
and so on) has always been a puzzler factory.if the choice is between
foo _
andfoo(_)
, then losing the first option isn't bad, but if the choice is betweenfoo _
andfoo(_, _, _, _, _, _)
then it starts feeling different.but in the wild, perhaps most uses of
foo _
would also compile simply asfoo
because a function type is already expected?personally, I think I tend to write
foo _
even when justfoo
would compile, just to explicitly signal to the reader thatfoo
is definitely not being called.The text was updated successfully, but these errors were encountered: