|
Re: Scala's Selfless Trait Pattern
|
Posted: Sep 9, 2009 10:07 AM
|
|
> Do you remember what first tipped you off that this could > be done? > I think it was born out of need. I wanted at one point to exercise ScalaTest's ShouldMatchers DSL in the interpreter, and realized it was not easy. It hit me that if I made a companion object to ShouldMatchers that mixed in the ShouldMatchers trait, it would let me import the whole DSL and use it in the interpreter. I then went looking for other opportunities to make the same thing possible. I did this with Assertions, but there may still be some more traits in ScalaTest I can do this with, because I think I may have one or two traits in there with self types that aren't necessary and should be removed. One of the items on my very short list of remaining things to do for the 1.0 release is look for extraneous self types that I can remove, and then apply this pattern to the trait.
|
|