> The core team will insist that variables are immutable but bindings are mutable
The documentation on the Elixir website refers to it as rebinding, and I don't see any references to bindings being considered mutable.
Rebinding means you've created a new binding with the same name. The original isn't being mutated, it's just not accessible anymore because of the scoping rules.
foo = 12
for x in xs {
foo = x + foo
}
It would always create a new foo binding in the for loop with value (12 + x);I think using Lisp syntax might help clarify, because it makes the binding scope explicit:
(let [foo 15]
(println foo) ; prints 15
(let [foo 12]
; prints 12
(println foo)
; prints 15
(println foo)))
> unlike a value which is actually a thing sitting in a memory slot in your vm.A mutable variable is a memory slot that can be mutated, though.