Proxies / delegates in Scala
I've seen several Scala questions recently (e.g. here , here , and here ) that called for the use of proxies, and it's come up more than once in my own work. The Scala library has a number of proxy traits (14, if I counted correctly). Proxy classes/traits usually contain lots of boilerplate: class FooProxy(val self: Foo) extends Foo { // added behavior def mymethod = ... // forwarding methods def method1 = self.method1 def method2(arg: String) = self.method2(arg) ... } trait Foo { def method1: Unit def method2(arg: String): Unit } My first thought was to define a Proxy[T] trait that could be