title: How to define a function that takes a function literal (with an implicit parameter) as an argument?
body: <p>I want to be able to do something on these lines (won't compile):</p>
  
  <pre><code>def logScope(logger:Logger)(operation: (implicit l:Logger) =&gt; Unit) {/* code */ operation(logger) /* code */} 
  def operationOne(implicit logger:Logger) {/**/}
  def operationTwo(implicit logger:Logger) {/**/}
  </code></pre>
  
  <p>And then use it like so:</p>
  
  <pre><code>logScope(new ConsoleLogger){logger =&gt;
      operationOne
      operationTwo
      }
  </code></pre>
  
  <p>But the nearest I've come to a working solution is this:</p>
  
  <pre><code>def logScope(logger:Logger)(operation: Logger =&gt; Unit) {/* code */ operation(logger) /* code */} 
  def operationOne(implicit logger:Logger) {/**/}
  def operationTwo(implicit logger:Logger) {/**/}
  
  /* other code */
  
  logScope(new ConsoleLogger){logger =&gt;
      implicit val l = logger
      operationOne
      operationTwo
      }
  </code></pre>
  
  <p>I don't think the language currently allows such constructs, but still, any suggestions or workarounds to achieve similar results?</p>
  
  <hr>
  
  <p>minor update: I've <a href="https://gist.github.com/1147757" rel="nofollow">created a gist</a> with a slightly expanded version of the above code with a couple of attempts at simulating this kind of literal. As of now, CheatEx's version is the best one.</p>