Re: Overloading methods with multiple parameter lists makes for "syntactic mismatch"
Nils Kilden-Pedersen <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CABDULvVzciA++PEM+85tTCZbgDDOje+dWtJ3EDih98JPeLHuyw@mail.gmail.com> |
On Thu, Jul 9, 2015 at 6:18 PM, mar <[email protected]> wrote: > The following compiles without warnings: > > object X { > def a(x: Int) = x > def a(x: Int)(y: Int) = x + y > } > > Actually trying to use either method gives me a compilation error even > though, in my mind, there is no ambiguity: X.a(1) without curryscore > would be the first one whereas X.a(1)(2) is the second. > > Defining *a* such that implicit val zero = 0; def a(x: Int)(implicit y: > Int) = x + y is a less-than-optimal workaround but what strikes me is > that in this case Scala is able to figure out the signature when explicitly > providing the second parameter item. Why is it eagerly failing in the first > case when it awaits the possible explicit value in the second? > > I find this rather confusing and "mentally overloading" > https://issues.scala-lang.org/browse/SI-2628 > -- > You received this message because you are subscribed to the Google Groups > "scala-language" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.