title: Performance difference between functions and pattern matching in Mathematica
body: <p>So Mathematica is different from other dialects of lisp because it blurs the lines between functions and macros. In Mathematica if a user wanted to write a mathematical function they would likely use pattern matching like <code>f[x_]:= x*x</code> instead of <code>f=Function[{x},x*x]</code> though both would return the same result when called with <code>f[x]</code>. My understanding is that the first approach is something equivalent to a lisp macro and in my experience is favored because of the more concise syntax.</p>
  
  <p>So I have two questions, is there a performance difference between executing functions versus the pattern matching/macro approach? Though part of me wouldn't be surprised if functions were actually transformed into some version of macros to allow features like <code>Listable</code> to be implemented. </p>
  
  <p>The reason I care about this question is because of the recent set of questions <a href="https://stackoverflow.com/questions/4174791/preventing-avalanche-of-runtime-errors-in-mathematica">(1)</a> <a href="https://stackoverflow.com/questions/4176612/setting-up-diagnostic-error-messages-in-large-mathematica-projects">(2)</a> about trying to catch Mathematica errors in large programs. If most of the computations were defined in terms of Functions, it seems to me that keeping track of the order of evaluation and where the error originated would be easier than trying to catch the error after the input has been rewritten by the successive application of macros/patterns. </p>