Google Groups

Re: [scala-user] Conflict in signatures with default values--why?

Lukas Rytz Oct 21, 2011 1:33 AM
Posted in group: scala-user

On Fri, Oct 21, 2011 at 02:07, Ken McDonald <> wrote:
Huh, that's interesting, I wonder why that would be the case?

The reason is that we wanted a deterministic naming-scheme for the generated methods
which return default arguments. Inf you write

  def f(a: Int = 1)

the compiler generates

  def f$default$1 = 1

If you have two overloads with defaults on the same parameter position, we would
need a different naming scheme. But we want to keep the generated byte-code
stable over multiple compiler runs.
Perhaps they are thinking ahead to future possibilities might require these conditions to assure disambiguation?

Too, it's quite inconvenient. I've changed my code around so that relevant functions use curried argument lists, and  defaults in the second arg list are calculated based on values in the first arg list--but it makes the code rather more obtuse, and I'm still running into corner casesl

Thanks Tony,