On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote:
There are actually (at least) TWO distinct phases of
compilation that are conventionally labelled "compile time":
1) Template expansion / AST manipulation, and:
2) CTFE (compile-time function evaluation).
[ ... ]
Template expansion / AST manipulation must be completed
*before*
CTFE can run.
Only the templates that the ctfe relies on.
[ ... ]
This is because it makes no sense to generate code on an
incomplete / partial AST.
This is not exactly true whenever you use ctfe to generate a
source string that you later mix-in. You are working with a
partial ast.
Furthermore, once a piece of code has made it to the CTFE
stage, its AST has already been processed, and it's now
compiled into an internal representation (analogous to
bytecode), so AST-manipulating constructs no longer make any
sense.
Yes.
In the CTFE stage, there is no such thing as an AST anymore.
There is an AST. It's just already processed.