r/Compilers • u/matthieum • Jul 28 '26
Inside Zig's Incremental Compilation | mlugg
https://mlugg.co.uk/posts/incremental-compilation-internals/
47
Upvotes
r/Compilers • u/matthieum • Jul 28 '26
View all comments
Show parent comment
0
u/mamcx Jul 29 '26
What you see in the article is the reason, the thing is that ""AST", in the pedantic way, is the "abstract" program, the one that is the true execution and semantic truth.
If the lang is simple enough you don't care about the distinctions, but the more complexity the more being "abstract" goes against your goals.
So, to be clear: The AST should not have macros at all, that is something that was solved in and early pass.
In general, there is a step of "desugaring" where the special cases and shortcut are normalized into canonical forms (for example all iterator magic is removed away), and in some langs, that is also removed away to be even more "abstract" where is not possible anymore to cleanly map back to the source code.
So all of this is purely in terms of necessity, where you get
Source code -> ? * N steps -> AST -> ? * N steps -> Final output OR execution(If you look at "nano pass" is argued that have dozen, thousands of step is cool)