Overloading methods with multiple parameter lists makes for "syntactic mismatch"
mar <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
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"
--
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.