1 / 26
Jun 2024

post by daniel-pfeiffer on Jun 23, 2024

“Variable” means “that which can vary”, i.e. the exact opposite of “immutable.” That is illogical and confused my for quite some time, when I was new. I see this at least in compiler error messages, “The Rust Programming Language” and even explicitly wrong in “The Rust Reference.”

I suggest gradually replacing these words by “immutable binding” everywhere. The word “variable” should be limited to “mutable bindings” to make sence.

Other uses of the word “variable” should be checked if they align with this. E.g. the unused_variables lint should become unused_bindings with the old name as an accepted alias, maybe deprecated in the 2027 edition.

read 11 min

post by quinedot on Jun 24, 2024

"Immutable binding" still doesn't capture reality, given interior mutability.

post by 8573 on Jun 24, 2024

I don't think it's the exact opposite; that's "invariable". "Immutable" means the variable cannot be changed , which I don't think necessarily means that it cannot vary (e.g., across different executions of a function).

I can understand it confusing beginners, though.

post by tczajka on Jun 24, 2024

I think the term "binding" is confusing in Rust context. It suggests that there is an object out there, and then separately there are bindings that bind to it. In other words, it suggests a reference .

Here is what Wikipedia says, confirming my intuition:

In programming languages , name binding is the association of entities (data and/or code) with identifiers . [1] An identifier bound to an object is said to reference that object.

It makes more sense to call Python or ML variables "bindings" because they are always references than refer to objects on the heap, and you can have multiple variables binding to the same object.

post by steffahn on Jun 24, 2024

post by daniel-pfeiffer on Jun 24, 2024

post by kornel on Jun 24, 2024

post by tczajka on Jun 24, 2024

post by daniel-pfeiffer on Jun 24, 2024

post by daniel-pfeiffer on Jun 24, 2024

post by tczajka on Jun 24, 2024

post by daniel-pfeiffer on Jun 24, 2024

post by tczajka on Jun 24, 2024

post by kornel on Jun 24, 2024

post by tczajka on Jun 24, 2024

post by kornel on Jun 25, 2024

post by tczajka on Jun 25, 2024

post by danjl1100 on Jun 25, 2024

post by tczajka on Jun 25, 2024

post by kornel on Jun 25, 2024

Load more posts below