In the “Programming Erlang” book it’s said that the language uses “single assignment” variables. In other articles about functional programming languages I always read of “immutable values” instead.
Does the wording “single assignment” mean something different from “immutable values”?
In erlang, a variable can be either bound or unbound. You can only assign a value to an unbound variable. And that’s where the single assignment comes from, because once the variable is bound, you can no longer assign a new value to it. So in erlang, you can’t do the following, even if
0and1are immutable values.The term immutable is relative to the value of the variable, and not the variable itself. So in some languages, you can assign to the same variable different values that are immutable:
Edit: From wikipedia
Immutable Object:
Single Assignment: