-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1-basics: variability vs mutability #13
Comments
Good point. I'm trying to speak to the usual sense of 'variable' in programming, but it's more the mathematical sense here. And 'variable' vs 'constant' is the important thing. |
@stevedonovan They're the same meaning! It's just that the defaults differ, like with references. |
I've fleshed it out a little. Yes, variables are variables. But the mutable default that is so common confuses people. |
Should this be closed with the changes you made? They seems good enough. |
"immutable variable" is an oxymoronic contradiction in normal english. |
@pannous In some sense "variable" is short for "variable binding" - the value inside is the variable, and what you're mutating is the "variable binding", not the value (which varies for a different reason than mutation - e.g. function arguments can differ between calls). |
I already tried to summarize it at rust-lang/book#276 (comment) for the second-edition book.
But the very short version of it is:
And the reason "immutable variable" is confusing is because all variables in some languages are mutable by default (i.e. without
const
orfinal
), not because "variable" implies mutability.(You may already know all of this, but I wanted to make sure we're not promoting "it is so because we say so" explanations, when the terms we use are consistent with other disciplines, e.g. mathematics)
The text was updated successfully, but these errors were encountered: