This not-well-documented option of Compile has been used quite a bit in this site, and based on these examples, I used to think "InlineExternalDefinitions" -> True only works for
- Compilable numbers
- Compilable pure functions
- Compiled functions
until the day I was astonished by George Varnavides: “Symmetry in Chaos” (128 characters). In this example, a non-numeric Symbol is inlined! The relevant part can be boiled down to the following example:
a = #;
cf = Compile[{c}, Nest[a &, c, 10],
CompilationOptions -> {"InlineExternalDefinitions" -> True}];
<<"CompiledFunctionTools`"
CompilePrint@cf
So my question is,
Is this example just a special case, or it represents a family of expressions that can be inlined by
"InlineExternalDefinitions" -> True?Is there other type(s) of inlineable expressions? Has anyone already summarized it?
P.S. George's code piece is quite tricky, if you have trouble in understanding it, consider posting a new question like "why does George's code work?".

"InlineExternalDefinitions" -> Trueis very similar to usingWith. For examplef1 = Sin[x^2]; cf1 = Compile[ {{x}}, f1, CompilationOptions -> {"InlineExternalDefinitions" -> True}]; CompilePrint[ cf1](a case not covered by your list) is like usingWith[{f2 = Sin[x^2]}, cf2 = Compile[ {{x}}, f2, CompilationOptions -> {"InlineExternalDefinitions" -> False}]; CompilePrint[ cf2] ]. There might be special cases (recursion?) were this analogy fails. – Karsten7 Jun 05 '17 at 11:42With[{mid = Sin[x^2]}, Compile[{x}(*notice the seemingly trivial modification here*), mid]] // CompilePrintisn't compiled. ) 2. I think"InlineExternalDefinitions"->Trueisn't that similar toEvaluateorHoldAll, because e.g.f1 = Sin[x^2]; cf = Compile[{{x, _Real, 1}}, First[f1], CompilationOptions -> {"InlineExternalDefinitions" -> True}]; CompilePrint[cf]can't be implemented with these technique. – xzczd Jun 05 '17 at 12:11"InlineExternalDefinitions" -> Trueeven changed between v9 and v10. – Karsten7 Jun 05 '17 at 12:59