top | item 41242095

Basic MetaProgramming in Zig

104 points| nalgeon | 1 year ago |openmymind.net

7 comments

order

dsp_person|1 year ago

> I wish there was a way to get Zig code out of comptime

I often just take an approach similar to cog [1], but it's simple enough I prefer to roll my own to do whatever code generation I'm wanting. E.g. write a ~100 line python file that reads source file(s), reads special comments with code gen or introspection instructions, and then insert generated code at some designated point(s).

[1] https://github.com/nedbat/cog

dragonelite|1 year ago

That was an interesting blog post, hope we will get more intermediate and advance zig usage blog posts and in the future books about zig.

anonymoushn|1 year ago

The language is deliberately pretty small. "Advanced usage" will tend to have to do with the problem domain and solution architecture rather than with the language.