New EEP draft: Pinning operator ^ in patterns

Raimo Niskanen raimo+erlang-questions@REDACTED
Fri Jan 15 15:40:38 CET 2021

On Fri, Jan 15, 2021 at 03:15:44PM +0100, Nicolas Martyanoff wrote:
> 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.

Correct me if I am wrong, but Erlang does not have unification.  Instead it
has got matching vs. binding, which are two different operations, as opposed
to unification where both sides of the unification are equivalent.

> 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
> so.
> -- 
> Nicolas Martyanoff
> khaelin@REDACTED


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list