- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Wouldn't it be nifty if this worked?
Fri, 2011-10-21, 08:52
I understand why it doesn't, but wouldn't it be super cool if it did?
Is there another way of accomplishing the same thing?
trait Dave { def foo : String }
class Delegate(underlying : Dave) extends Dave {
import underlying._
// delegate now implements all of Dave's methods, delegating to the
underlying impl
}
you can do this with the autoproxy compiler plugin, i believe:
https://github.com/kevinwright/Autoproxy-Lite
i think this is really a common design pattern, so i hope something comes out of this project:
https://github.com/TiarkRompf/scala-virtualized
which notes as a key feature: "transparent proxies: re-route all method calls on these proxy objects to a forwarder method".
(-offtopic- i'm personally hoping for a removal of the "new" keyword, so that you could do something like
trait Graph {
def funkyStuff : Int
}
object DSL {
def graph( body: @new[ Graph ]) : Graph = ???
}
import DSL._
graph { funkyStuff + 33 }
)
best, -sciss-
On 21 Oct 2011, at 08:52, Aaron wrote:
> I understand why it doesn't, but wouldn't it be super cool if it did?
> Is there another way of accomplishing the same thing?
>
>
> trait Dave { def foo : String }
>
> class Delegate(underlying : Dave) extends Dave {
> import underlying._
> // delegate now implements all of Dave's methods, delegating to the
> underlying impl
> }
>
>