I always interpreted the spec to mean that the implicit can be defined in the companion object of the implicit parameter, not the class containing the definition. Something like this: object ZZ { implicit val xyz: ZZ = new ZZ() } class ZZ { def bar: (String) => Unit = null } class XX { def foo(s: String)(implicit f: ZZ): Unit = { if (f. Bar == null) println("Just: " + s) else f.
Bar(s) } def bar { foo("xyz") } } It seems clear in Section 7.2 of the spec: The actual arguments that are eligible to be passed to an implicit parameter of type T fall into two categories. First, eligible are all identi� Ers x that can be accessed at the point of the method call without a pre�
X and that denote an implicit de� Nition (§7.1) or an implicit parameter. An eligible identi�
Ermay thus be a local name, or a member of an enclosing template, or it may be have been made accessible without a pre� X through an import clause (§4.7). If there are no eligible identi�
Ers under this rule, then, second, eligible are also all implicit members of some object that belongs to the implicit scope of the implicit parameter’s type, T Can you quote the part that indicates the companion object of the containing class of the definition?
I always interpreted the spec to mean that the implicit can be defined in the companion object of the implicit parameter, not the class containing the definition. Something like this: object ZZ { implicit val xyz: ZZ = new ZZ() } class ZZ { def bar: (String) => Unit = null } class XX { def foo(s: String)(implicit f: ZZ): Unit = { if (f. Bar == null) println("Just: " + s) else f.
Bar(s) } def bar { foo("xyz") } } It seems clear in Section 7.2 of the spec: The actual arguments that are eligible to be passed to an implicit parameter of type T fall into two categories. First, eligible are all identiï¬ers x that can be accessed at the point of the method call without a preï¬x and that denote an implicit deï¬nition (§7.1) or an implicit parameter. An eligible identiï¬ermay thus be a local name, or a member of an enclosing template, or it may be have been made accessible without a preï¬x through an import clause (§4.7).
If there are no eligible identiï¬ers under this rule, then, second, eligible are also all implicit members of some object that belongs to the implicit scope of the implicit parameter’s type, T. Can you quote the part that indicates the companion object of the containing class of the definition?
Seems I misunderstood which class the companion object had to be associated with. Thanks for clearing it up for me. I'm trying to find a way to define a "default function" that can be passed to another function.
But can be overridden by the caller. – Curt Sellmer Jan 20 at 17:49 I assume your "default function" could be implemented as a default argument. Scala-lang.Org/node/2075 – Mitch Blevins Jan 20 at 17:55.
This is also how various collection methods expecting CanBuildFrom work: the implicits are found inside companion objects to the type parameters of CanBuildFrom. I haven't actually seen examples of this. I'd be grateful if someone could share one.
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.