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
implicit methods behave suboptimally when used non-implicitly #3781
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3781?orig=1 |
@harrah said: |
@paulp said:
Thank you, I looked but didn't find the right spot. So I guess the question is whether a method with an implicit argument is to be eta-expanded. The spec says "Otherwise..." for eta expansion, which sounds like it means that if a method takes only implicit parameters, it stops before eta expansion. But I don't know why we wouldn't want them to expand from (implicit T)R to T => R. Is there some obvious reason to squelch it? |
@adriaanm said: |
@lrytz said: |
@odersky said: f _ == f(_) == (x => f(x)) But only the second equality holds. The reason lies i the parser. It eta-expands What to do about it? The proper thing to do would be to force eta-expansion |
@harrah said: |
@odersky said: |
@paulp said:
I would miss f _. I use it a lot, although maybe there are other ways to do things. Is there another way to turn a method into a function without knowing the arity first? Maybe that seems like a trivial thing but I get a lot of mileage in the repl, especially with java's ridiculously long everything. scala> java.lang.management.ManagementFactory.newPlatformMXBeanProxy _
res0: (javax.management.MBeanServerConnection, java.lang.String, java.lang.Class[Nothing]) => Nothing = <function3>
scala> java.util.Arrays.deepEquals _
res1: (Array[java.lang.Object], Array[java.lang.Object]) => Boolean = <function2> |
And the monkey wrenches really go flying if you throw in another one:
I suppose we're in unspecified land here, but I think it'd be nice if we could say implicit methods don't move one in multiple directions away from non-implicit ones (by which I mean, make it implicit and now THIS works but THIS doesn't...) because it's rather tedious trying to push all that toothpaste back into the tube.
The text was updated successfully, but these errors were encountered: