This is very much a fine use case. I actually recommend this when scope determines the parameter to use. It provides an elegant way to pass some sort of context into a Plugin class so that utility functions will use the context.
For example: trait Context object UtilityLib { def performHandyFunction(implicit x : Context) : SomeResult = ... } trait Plugin { def doYourThing(implicit ctx : Context) : Unit } class MyPlugin extends Plugin { def doYourThing(implicit ctx : Context) : Unit = { UtilityLib. PerformHandyFunction } } SomePluginAPI. Register(new MyPlugin) You can see an example in a database migration system I was toying Check out the Migration class and its MigrationContext.
This is very much a fine use case. I actually recommend this when scope determines the parameter to use. It provides an elegant way to pass some sort of context into a Plugin class so that utility functions will use the context.
For example: trait Context object UtilityLib { def performHandyFunction(implicit x : Context) : SomeResult = ... } trait Plugin { def doYourThing(implicit ctx : Context) : Unit } class MyPlugin extends Plugin { def doYourThing(implicit ctx : Context) : Unit = { UtilityLib. PerformHandyFunction } } SomePluginAPI. Register(new MyPlugin) You can see an example in a database migration system I was toying.
Check out the Migration class and its MigrationContext.
Yes, I can see how this is useful. The use case that prompted the question is sort of along those lines, although I didn't think of the word "context"... – huynhjl Nov 11 '10 at 0:43.
It doesn't really look like an idiomatic use of implicits, which tend to be suited for type classes and dependency injection. There's absolutely no point in passing about a class with no members... It's also more common to define an implicit val or object of type I before making the call to (new B). Foo Having said all that, you supplied an obviously a very abstract example.So it's not too hard to imagine a reasonable use-case for implicits that follows a similar pattern.
The following example from A Tour of Scala shows how implicit can be used to provide the appropriate missing members (add and unit) based on the type. The compiler will pick the right implicit object in scope. The library also uses that with List.
SortBy and Ordering or List.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.