3 ms·
Zig doesn't have variable length args. The .{} syntax is for an anonymous struct with no field names (which are named tuples in Zig.) Print takes the struct's
by Laremere 4y ago
Zig doesn't have variable length args. The .{} syntax is for an anonymous struct with no field names (which are named tuples in Zig.) Print takes the struct's type info at compile time to check the validity of the statement, and also produce optimal code. This is implemented entirely within Zig's standard functionality that's available to all users.
So, if you just type X, you're getting an error about it not being a struct. That's unless X is a struct with one field, where it'll just print that field.
I find Zig meta-programming to actually be fairly readable, here's the function that does the formatting: https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig