When you write a method that forwards some parameters to another method, you have to repeat any parameter defaults:
def foo(x: Int = 42) = ???
def bar(
x: Int = 42 // need to repeat this default
) = foo(x)
I find this rather irritating because I might want to change the default some day, and have the default apply everywhere in the codebase. OK, I can factor the default out in a val, but often I don’t control the definition of the function that I’m calling (e. g. foo might be defined in a library).
Could we make the defaults available somehow? Perhaps we could allow something like this:
def foo(x: Int = 42) = ???
def bar(
x: Int = default(foo.x)
) = foo(x)
Perhaps this could even be implemented as a macro?
That is off-the-cuff, but the class extension use case is an old complaint, especially because of shadowing, which would not apply for “signature extension” of methods.