Re:Why Zig When There Is Already CPP, D, and Rust? (2017)
by mborch on Monday October 15, 2018 @02:38AM
(#18217834)
What it does have is compile-time parameters where you can bind a type variable during compilation:
fn max(comptime T: type, a: T, b: T) T {
if (T == bool) {
return a or b;
} else if (a > b) {
return a;
} else {
return b;
}
}
The type variable isn't used at run-time.
I'm not sure how to reconcile this statement with the following claim from the linked article: "Zig has no macros and no metaprogramming yet still is powerful enough to express complex programs in a clear, non-repetitive way." Not only does it claim that Zig has no metaprogramming, it suggests that it sees metaprogramming as undesirable.