title: How to pass functions as arguments to other functions in Julia without sacrificing performance?
body: <p><strong>EDIT</strong> to try to address @user2864740's edit and comment: I am wondering if there is any information particularly relevant to 0.4rc1/rc2 or in particular a strategy or suggestion from one of the Julia developers more recent than those cited below (particularly @StefanKarpinski's Jan 2014 answer in #6 below). Thx</p>
  
  <p>Please see e.g.</p>
  
  <ol>
  <li><a href="https://groups.google.com/forum/#!topic/julia-users/pCuDx6jNJzU" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/julia-users/pCuDx6jNJzU</a></li>
  <li><a href="https://groups.google.com/forum/#!topic/julia-users/2kLNdQTGZcA" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/julia-users/2kLNdQTGZcA</a></li>
  <li><a href="https://groups.google.com/forum/#!msg/julia-dev/JEiH96ofclY/_amm9Cah6YAJ" rel="nofollow noreferrer">https://groups.google.com/forum/#!msg/julia-dev/JEiH96ofclY/_amm9Cah6YAJ</a></li>
  <li><a href="https://github.com/JuliaLang/julia/pull/10269" rel="nofollow noreferrer">https://github.com/JuliaLang/julia/pull/10269</a></li>
  <li><a href="https://github.com/JuliaLang/julia/issues/1090" rel="nofollow noreferrer">https://github.com/JuliaLang/julia/issues/1090</a></li>
  <li><a href="https://stackoverflow.com/questions/21053491/can-i-add-type-information-to-arguments-that-are-functions-in-julia">Can I add type information to arguments that are functions in Julia?</a></li>
  <li><a href="https://stackoverflow.com/questions/26173635/performance-penalty-using-anonymous-function-in-julia">Performance penalty using anonymous function in Julia</a></li>
  </ol>
  
  <p>(As a fairly inexperienced Julia user) my best synthesis of this information, some of which seems to be dated, is that the best practice is either "avoid doing this" or "use <a href="https://github.com/timholy/FastAnonymous.jl" rel="nofollow noreferrer">FastAnonymous.jl</a>."</p>
  
  <p>I'm wondering what the bleeding edge latest and greatest way to handle this is.</p>
  
  <p>[Longer version:]</p>
  
  <p>In particular, suppose I have a big hierarchy of functions. I would like to be able to do something like</p>
  
  <pre><code>function transform(function_one::Function{from A to B},
                     function_two::Function{from B to C},
                     function_three::Function{from A to D})
      function::Function{from Set{A} to Dict{C,D}}(set_of_As::Set{A})
          Dict{C,D}([function_two(function_one(a)) =&gt; function_three(a)
                     for a in set_of_As])
      end
  end
  </code></pre>
  
  <p>Please don't take the code too literally. This is a narrow example of a more general form of transformation I'd like to be able to do regardless of the actual specifics of the transformation, BUT I'd like to do it in such a way that I don't have to worry (too much) about checking the performance (that is, beyond the normal worries I'd apply in any non-function-with-function-as-parameter case) each time I write a function that behaves this way.</p>
  
  <p>For example, in my ideal world, the correct answer would be "so long as you annotate each input function with <code>@anon</code> before you call this function with those functions as arguments, then you're going to do as well as you can without tuning to the specific case of the concrete arguments you're passing."</p>
  
  <p>If that's true, great--I'm just wondering if that's the right interpretation, or if not, if there is some resource I could read on this topic that is closer to a "logically" presented synthesis than the collection of links here (which are more a stream of collective consciousness or history of thought on this issue).</p>