←back to thread

498 points azhenley | 1 comments | | HN request time: 0.216s | source
Show context
gethly ◴[] No.45769775[source]
Variable is by definition mutable.

Constant is by definition immutable.

Why can't people get it through their heads in 2025? (I'm looking at you, Rust)

replies(4): >>45769884 #>>45769977 #>>45770214 #>>45770314 #
1. m000 ◴[] No.45769977[source]
Depends on how you look at it.

A true constant won't change between runs of the code. I.e. it is essentially a symbolic name for a literal.

A constant variable OTOH, varies in different executions of the code. So, its invariance is linked to an execution context.