Zig NEWS

loading...

Discussion on: Crafting an Interpreter in Zig - part 2

Collapse
kristoff profile image
Loris Cro

I've never done a Crafting Interpreters run, but I'm happy to follow along your experience. It's a bit like watching somebody on Twitch do a full run of a game. Keep it up!

I have two comments that might interest you about the content:

I hope that Zig inline this function calls.

You can use the inline keyword to enforce this. Compilation will fail if for some reason Zig will not be able to inline a call so you know for sure that those functions will be functionally equivalent to the original C macro.

If you now a better way or have an idea on how to solve this problem in different and interesting way, please let me know.

One thing that you can do is mark the op argument as comptime, which will allow Zig to resolve the switch at comptime, basically making the function equivalent to the C macro.

fn binary_op(self: *Self, comptime op: BinaryOp) void
Enter fullscreen mode Exit fullscreen mode

One final suggestion: Forem supports article series, go in the edit page of your first article and there you will find an option to create a series, then go to the edit page of this new one and add it to the same series. Doing so will add a neat table of content at the top of each post that gets automatically updated when you add a new one.

Cheers!