3 ms·
> Rust’s variable bindings are immutable by default, but can become mutable, allowing them to be re-bound to something else From someone reading about these de
by hackuser 12y ago
> Rust’s variable bindings are immutable by default, but can become mutable, allowing them to be re-bound to something else
From someone reading about these details for the first time:
Calling them variable bindings confuses the matter. You say, just moments earlier, that variables are called by that name because they can change over time, they’re mutable. But this variable is immutable? But only sometimes? !
I know you mean that the mutability varies and that it makes sense in the context of the jargon of functional languages, but that's something that will make sense to language developers who have worked on Rust for years and maybe to the HN crowd, and not to new coders trying to grasp difficult, novel (to them) concepts.
How about "multimode bindings" or "multiphase bindings" (as in liquid/solid phase transitions) or dual-mode or something more entertaining like "double-agent bindings". Is it too late to change?
Maybe I'm missing something, but I suspect years from now people will be saying, 'so variable bindings are not always variable? huh?'
- dbaupp 12y ago'Variable' is a jargon-y term in mathematics/programming in general, it doesn't literally mean "this thing can vary in the run of this program", e.g. even Haskell calls its name bindings "variables", and it is focused on immutability much more than Rust (I suppose this is the functional programming aspect you were mentioning). One way to view it is that the bindings don't have a value that is fixed at compile time: they vary between runs. In any case, I'm not sure what you mean by "mutability varies".
- kibwen 12y ago"Variable" means that the value within can vary, as opposed to a constant, where the value never varies. This has nothing to do with mutation. For instance, a function's arguments are always variables as the value within each argument can vary each time the function is invoked, and they are variables regardless of whether or not the function ever mutates them.
- MichaelGG 12y agoOr just drop variable completely and use just "bindings"? Perhaps with a note that this is similar to variables in other languages.
- nercury 12y agoWhen faced with similar confusion, I used "bound value" instead of "variable". I thought it might be better.