New EEP draft: Pinning operator ^ in patterns
Fri Jan 15 15:15:44 CET 2021
On 2021-01-15 13:34, Richard Carlsson wrote:
> Imagine a world where Erlang had not allowed already-bound variables in
> patterns (forcing you to use the idiom "X1 when X1 =:= X -> ...", as in
> e.g. Haskell), and that someone now came with the suggestion that to make
> things simpler, we could just implicitly match on the value of X if X is
> already bound. The old me from my university days would probably have said
> "that's really elegant, let's do it". But the
> maintainability-and-readability me, with experience of very large code
> bases, large numbers of developers, and many relative newcomers to the
> language, would say "aw hell no". This is a cute feature, but it carries a
> large cognitive cost and is not worth having compared to how relatively
> little it is used. Being explicit about intention is much more important.
Unification is not a "cute feature" and it is not just about "implicitly
matching" values, it is a fundamental part of Prolog, and thus of Erlang.
Developers who are not used to the concept may be wary about this part of the
language, but learning is a process everyone is welcome to.
One of the reasons I ended up using Erlang was to escape the insanity of other
languages, which became more and more complex because saying "no" is so much
harder than caving in to requests. The Erlang/OTP team at Ericsson has done a
good job keeping the language sane for years, and I hope they continue to do
More information about the erlang-questions