4 ms·
> I cant think of a single real use case for variadic generics. Even if you could think of one, I personally think the rust community does a poor job of weighi
by norir 3y ago
> I cant think of a single real use case for variadic generics.
Even if you could think of one, I personally think the rust community does a poor job of weighing the tradeoff between supporting a niche feature and adding complexity to the language. Rust is already so huge that all but the most dedicated have little hope of understanding even half of the language features. I'm not sure I understand the incentive structure that makes it this way, but it is hard for me to see how rust avoids becoming the next c++ unless they learn how to say no. Honestly I believe it's already too late and that rust's best ideas will be adopted by a smaller language with better ergonomics, compiler performance and learnability that will eat its lunch.
- Georgelemental 3y agoThe status quo is that people who would like to use variadics but can't, instead settle for complicated ad-hoc macros. Those are far worse for "ergonomics, compiler performance and learnability."
- MrBuddyCasino 3y agoInstead of extending the language with ever more niche features, they could pull a Zig and make macros not suck.
- SkiFire13 3y agoZig's `comptime` is not a silver bullet though: - it is duck typed, which to be fair macros are also, but variadic generics would be type checked at the definition; - it interacts badly with traits, that is if you allow both querying for implemented traits and creating new trait `impl`s then this can create cycles in the execution of comptime blocks, meaning the compiler needs to compute a fixpoint or arbitrarily give an error.
- Georgelemental 3y agoAlso, Rust has lifetimes which are erased prior to monomorphisation—so specializing based on them is unsound. Any `comptime` equivalent in Rust would have to limit the access of `comptime` blocks to lifetime information in some way.