3 ms·
I'm wondering if Zig's generics are a good way forward nonetheless? Much like TypeScript added type-checking to JavaScript, a future version of Zig could add ty
by skybrian 4y ago
I'm wondering if Zig's generics are a good way forward nonetheless? Much like TypeScript added type-checking to JavaScript, a future version of Zig could add type constraints that can be used on comptime variables to catch common errors.
(They probably won't be sound type constraints, but maybe that's not that big a deal, since the result would be a worse compile error at instantiation time.)
- User23 4y agoSoundness is of relatively minor importance on account of rejecting the occasional correct program is a reasonable price to pay for rejecting all incorrect programs. Especially when you can allow the programmer to hint the analyzer.
- tialaramex 4y ago> rejecting the occasional correct program is a reasonable price to pay for rejecting all incorrect programs I agree with you, but the C++ language disagrees very strongly, the set phrase in the C++ standard is "Ill-formed, no diagnostic required". ie the compiler isn't required to do anything sane in this case, but it also isn't required to emit a warning or error.