Comptime text processing

Zig claims it uses comptime calculation instead of textual macro to achieve meta programming at some points.

Today, I meet a situation like Rust’s syn and paste that I want to generate a series of struct and functions with specified suffix, but I don’t not if Zig supports define functions/structs’ name in a programmatic way comptime.

Hey @tison, I think this would be a great candidate for the Translation category. If you create a thread there, we can have several people take a crack at it and let the community vote on what would be the best way to handle this. Macros seem to get a lot of attention there :slight_smile:

Updated. Let’s see :smiley:

To get the voting functionality to work, you need to remake the thread as a Translation thread sepcifically - it won’t bring in the voting functionality if you change this thread’s category.

In the translation category you’ll see some guidelines posted there (such as including a usage example for making users to use as a reference). @chung-leong has made some great posts there - check out the latest one for reference C/C++ macro challenge #3: omitting an argument

Please make a new thread in the translation category and check out those guidelines so we can best help you get your problem solved :slight_smile:

I’m changing the category back to Help so we can keep this one here if you choose to make a new thread (otherwise, we get categories that seemingly don’t have the same functionality).

This is not possible currently. @Type() does not accept a structure contain decls. We have to wait til #6709 gets implemented.