4 ms·
Variable bindings in Erlang are immutable to support the pattern matching. If variable bindings were not immutable, then Erlang would need syntax to distinguis
by frognibble 17y ago
Variable bindings in Erlang are immutable to support the pattern matching. If variable bindings were not immutable, then Erlang would need syntax to distinguish between free and fixed variables in a pattern. The "=" in Erlang is pattern match, not assignment. Erlang could make bindings mutable without impacting the concurrent nature of Erlang because values would still be immutable.
- xtho 17y agoIt nevertheless is confusing for somebody who doesn't know erlang. Even prolog uses different symbols for matching a variable and for defining a clause.
- rvirding 17y agoIt is as you say, you must make a choice, trying to have both becomes very confusing. In LFE (Lisp Flavoured Erlang) I went the other and added proper scoping. It is the lack of scoping which I consider to be the most confusing and has caused some strange features. Having mutable variables is definitely possible but I don't really see the problems with immutable ones. You get used to it very quickly.