Zig NEWS

Discussion on: Crafting an Interpreter in Zig - part 4

Collapse
apatriarca profile image
Antonio Patriarca

I got the impression the book author is sometimes trying to show some C feature instead of taking the easier route. Even in C a switch would have been easier to write and understand IMHO. Each row has in fact only a few entries that are different from the default.

It is possible to obtain something similar in Zig as well anyway. You create an array big enough to contain all the tokens and you then initialize it at compile time with those values.