`definline` defines a Clojure function with an additional version that the compiler can substitute at direct call sites. It is useful for small, performance-sensitive wrappers around Java calls: substitution lets the caller’s type information reach the interop expression. Use it when the inline expression and ordinary function body are intended to do the same job. section 4.5 section 2.1.1
One definition, two forms
```clojure (definline timespi [x] `(* ~x 3.14)) (timespi 3) ;; 9.42 ``` Macro-expanding the declaration reveals a `defn` plus `:inline` metadata containing the substitution function. The backquoted expression supplies the inline form without requiring a separately written `:inline` implementation. section 4.5
Invocation matters. A direct call can use the inline form; passing the function as a value, as in `(map sq xs)`, uses the ordinary function. Keep both behaviors aligned. If an inline expression refers to an argument more than once, bind it first: `(let [x# ~x] (* x# x#))` evaluates the supplied expression once. section 4.5
public class IntegerMath { ; #1
public static int plus(Object op1, Object op2) {
System.out.println("int plus(Object Object)");
return ((Number) op1).intValue() + ((Number) op2).intValue();
}
public static int plus(Integer op1, Integer op2) {
System.out.println("int plus(Integer Integer)");
return op1 + op2;
}
public static int plus(int op1, int op2) {
System.out.println("int plus(int int)");
return op1 + op2;
}
//[...] other types
}
The overloaded `IntegerMath/plus` methods make overload selection visible: each prints the parameter types selected for that call. section 4.5
Keep caller types visible to Java
A normal `(defn plus [x y] (IntegerMath/plus x y))` selects `plus(Object, Object)` in the shown `map` example—even when the caller applies `int` to both arguments. Replacing it with `(definline plus [x y] `(IntegerMath/plus ~x ~y))` makes those direct calls select `plus(int, int)` instead; both versions produce `(4 5 6)` for the demonstrated inputs. section 4.5
`definline` is experimental, not a general replacement for `defn`. Prefer an ordinary function unless inlining addresses a concrete interop need; earlier Clojure releases also had a serious AOT-compilation issue. section 4.5 section 2.1.1
