INLINE EXPANSION paste the body at the call; the call vanishes
Replace a call with a copy of the callee’s body, its parameters bound to the arguments. The call overhead disappears and — more importantly — the body is now exposed to the caller’s context, so constants flow in and the other passes fire across the old boundary. The enabler optimisation. In I-13, with no closures, inlining is pure textual substitution — no environment to capture.
THE TECHNIQUE bind params, splice body, re-fold
Inline inc(inc(5)): paste inc’s body twice, bind the argument, and the constants collapse. Watch the call count fall to zero and the constant-fold finish the job: live demo
HISTORY & CREDIT procedure integration; 1970s onward
“Inlining always makes code faster.” — no. It trades code size for call overhead; over-inlining bloats the instruction cache and can slow things down. Every real inliner is a budget decision (size, call frequency), not an unconditional paste. cited
1970s · Allen & Cocke — procedure integration listed among the classical transformations; Scheer/Scheifler (1977) gives an early cost model for when integration pays. 1978 · Steele — RABBIT (a Scheme compiler) does procedure integration by beta-substitution; 1989 · Kelsey — compilation by program transformation (ORBIT), inlining as beta-reduction. Two separate lines (not co-authors), both on the no-closures / substitution view. 1990s+ · profile-guided inlining (SELF, Java HotSpot) — Ungar, Hölzle make it adaptive and speculative.
Inlining and tail-call elimination are complementary: inlining removes a call by copying, TCE (155) removes it by reusing the frame — a body you inline may still end in a tail call you then eliminate. Allen & Cocke; Scheifler, 1977
RECOMMEND FOR I-13 same value, zero calls
That inlining preserves the result — the called form and the pasted-and-folded form agree — holds on the canonical compiler:
$ i13 run inline.i13 # inc(inc(5)) vs ((5+1)+1)
called = 7 -- inc(inc(5)), two real calls
inlined = 7 -- ((5+1)+1), inc's body pasted twice; zero calls
Recommend: inline expansion is LIT and clean on I-13 — verified inc(inc(5)) and the hand-inlined ((5+1)+1) both give 7, with the inlined form making zero calls. Because I-13 has no first-class functions or closures (see dart 159), inlining is a pure parameter-for-argument substitution — no captured environment, no name capture beyond alpha-renaming — and it hands the spliced body straight to SCCP (151) and GVN (152). Guard it with a size budget.