I’ve implemented the cake pattern using structural types instead of wrapper traits. I am now wiring up my dependencies like this:
trait GreeterDependency { def greeter = HelloGreeter }
val printer = new Printer with GreeterDependency
It would be nice if I could do something like this instead:
val printer = new Printer with trait { def greeter = HelloGreeter }
However, I get a syntax error. Is there a way to define an unnamed trait and use it as a mixin like this?
(For clarity, here is all my code: http://ideone.com/vMDFYD)