title: How to implement intermediate types for implicit methods?
body: <p>Assume I want to offer method <code>foo</code> on existing type <code>A</code> outside of my control. As far as I know, the canonical way to do this in Scala is implementing an implicit conversion from <code>A</code> to some type that implements <code>foo</code>. Now I basically see two options.</p>
  
  <ol>
  <li><p>Define a separate, maybe even hidden class for the purpose:</p>
  
  <pre><code>protected class Fooable(a : A) {
    def foo(...) = { ... }
  }
  implicit def a2fooable(a : A) = new Fooable(a)
  </code></pre></li>
  <li><p>Define an anonymous class inline:</p>
  
  <pre><code>implicit def a2fooable(a : A) = new { def foo(...) = { ... } }
  </code></pre></li>
  </ol>
  
  <p>Variant 2) is certainly less boilerplate, especially when lots of type parameters happen. On the other hand, I think it should create more overhead since (conceptually) one class per conversion is created, as opposed to one class globally in 1).</p>
  
  <p>Is there a general guideline? Is there no difference, because compiler/VM get rid of the overhead of 2)?</p>