5 ms·
I wish they have used a different word than `const` for "not necessarily constant but it can be called at compile time". This is bound to confuse newcomers. Not
by juancampa 6y ago
I wish they have used a different word than `const` for "not necessarily constant but it can be called at compile time". This is bound to confuse newcomers. Note this is unrelated to this release but I just realized how confusing it could be.
- steveklabnik 6y agoThe downside there would be explaining how that new word maps to Rust's concept of const, unless you'd change all of that too.
- tempodox 6y agoLike `comptime` in Zig, I find that quite self-explanatory.
- steveklabnik 6y agoconst fns are not inherently evaluated at compile time, so that would be a misnomer.
- kevincox 6y agoMaybe `pure`. Then it is fairly straightforward to explain that the computation of `const` values must be `pure`.
- steveklabnik 6y agoFun fact: Rust did use "pure" a very long time ago... https://news.ycombinator.com/item?id=24295941 https://news.ycombinator.com/item?id=24295941 It has its own challenges. Consider: const fn foo(x: &mut i32) { *x += 1; } would you consider this function pure? I don't think many would. Also, it may be pure given Rust's semantics, but it kinda goes against the intuitive, usual way people talk about purity, so that makes it hard. (This is not yet stable in Rust, but will be.)