3 ms·
Instead of extending the language with ever more niche features, they could pull a Zig and make macros not suck.
by MrBuddyCasino 3y ago
Instead 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.