|
|
|
|
|
by FrozenVoid
1511 days ago
|
|
zig comptime is the same
as constexpr/consteval in C++
which operate on variables and
valid code blocks. C macros operate on arbitrary tokens, which
get converted to code or constants. For example variadic
functions can be implemented
to act on token arglists that
act as abstract tuples:
https://github.com/FrozenVoid/C-headers/blob/main/argmanip.h |
|
It's an explicit goal of the language that you can tell what the local control flow is by reading the code, but of course one is free to run the C preprocessor as part of the build if one disagrees.
I don't think C++ constexpr/consteval can be used to write things like generic json serializers and deserializers, which Zig does in the standard library using comptime, but I'm not sure.