For performance, it is sometimes useful to provide inlined code transformations that can be performed during compilation and expanded at the point of use. 


1) Optimization for constants. Given a square function, it would be useful to have the compiler perform the square operation at compile time and inline the result in the case where it's called with a constant. 

  (square 3)  could be evaluated and replaced with 9 in the compiled code.

  (map square xs)  would still need to be compiled as a function invocation.

2) Inlining calls to internal Java functions.

3) Optimization for particular arities.



The following constraints should be considered:


Compiler macros (from Common Lisp) are the proposed solution to this issue.


The existing implementation in Clojure is definline, which has issues in being used as a higher-order function.