Hacker News new | ask | show | jobs
by juancampa 2042 days 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.
2 comments

The downside there would be explaining how that new word maps to Rust's concept of const, unless you'd change all of that too.
Like `comptime` in Zig, I find that quite self-explanatory.
const fns are not inherently evaluated at compile time, so that would be a misnomer.
Maybe `pure`. Then it is fairly straightforward to explain that the computation of `const` values must be `pure`.
Fun fact: Rust did use "pure" a very long time ago... 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.)