News for hackers. Stuff that matters.
Re:Crabtime: Zig's Comptime in Rust by dwattttt on Saturday March 22, 2025 @05:48PM (#43448908)
There's two lookups that can occur, distinguishing them makes it clearer.

Looking up the value of an environment variable at runtime is not a const operation, and produces an error if you try to do it in a const fn.

Looking up the value of an environment variable during compile time _can_ be done in a const context, but it'll only happen once. The environment should be considered an input to a const fn, and that makes it "pure".

EDIT: These two operations can both be done in non-const functions too, they're different functions (well, one's a macro).

There are no comments on this comment yet.