Sweet. Doing these things with comptime is so much fun. I’m curious, does anyone have an article on how comptime is actually implemented in the Zig compiler? Is it an IR interpreter like C++ constexpr or Rust const?
Pretty much, zig uses an untyped IR (called ZIR) and performs semantic analysis and comptime evaluation on that to produce a typed IR (called AIR) which is then passed to the backend for code generation.
For more detail see https://mitchellh.com/zig/sema or src/Sema.zig in the zig repository.