Here’s @andrewrk’s answer:
Some more details from the compiler development Zulip:
i.e. a bespoke interpreter for bootstrapping zig 0.13.0. and then when 0.14.0 comes out it gets updated to be able to interpret exactly that source
I bet such an interpreter could operate directly on AST
and it wouldn’t really have to differentiate between comptime and runtime
My attempt at clarifying after I continually misunderstood the idea:
- the end goal is for the interpreter to take the compiler source code and run it without the intermediate steps in the “zig → wasm → c → compile zig1 → run zig1” chain. In other words, running the interpreter on the compiler source code should basically do what the compiled zig1 does, and the expected output is actually the same as the zig1-generated zig2.c since it’s the result of running zig1
- put another way, this is not a zig → c transpiler, that just happens to be the output when running zig1 with the arguments it’s passed
- in other other words, an interpreter…
- so, for the hello world, the expected result is
Hello World
printed to stdout (as mentioned)