Proposal to add Extension Methods to the language

Unless you’re calling a right-associative operator as a normal method. Currently the order of operands in a method definition matches that of a method call but with this new syntax for extension methods it matches the order in an operator application. This makes extension method definitions different from regular methods:

class C {
  // Normal method definition, argument list on the right (method style)
  def :: (x: Elem): C = ...
}

// Extension method definition, argument list on the left (operator style)
def (x: Elem) :: (xs: C): C - ...
2 Likes