Improve readability/learnability of extension methods

Maybe Scala could adopt a much simpler approach for extension methods.
Extension methods could be a thing syntactic sugar layer over method application.

case class A(x: Int, y: String)
...
def f(a: A)(b: B, c: C): D = ???
...
a.f(b, c)
// de-sugars to `f(a)(b, c)`, since
// * `A` doesn't have a member `f` and
// * `f: A => (B, C) => D` is in scope

It would also improve the situation, when you want to apply successively more functions. You would be able to do just this:

x.h.g.f

instead of this:

f(g(h(x))) // nested parentheses, so ugly and annoying to write

I wrote about this at more length a while back

4 Likes