|
|
|
|
|
by Veserv
589 days ago
|
|
I do not know Zig, but it looks like it just means "call default constructor for parameter/variable/type". I do not see how you could expect it to be elided unless every function auto-constructs any elided arguments or always has default arguments. In other words, for a function f(x : T), f(.{}) is f(T()), not f(), where T() is the default constructor for type T. If we had a function with two parameters g(x : T, y : T2) it would be g(.{}, .{}) which means g(T(), T2()), not g(). It looks like the feature exists to avoid things like: x : really_long_type = really_long_type(), which can be replaced with x : T = .{} to avoid unnecessary duplication. |
|
They should add default parameters to avoid this sort of thing. Maybe they ought to consider named/labelled parameters, too, if they're so concerned about clarity.
0: https://github.com/ziglang/zig/issues/484