New EEP draft: Pinning operator ^ in patterns

Raimo Niskanen raimo+erlang-questions@REDACTED
Mon Jan 18 22:22:57 CET 2021

On Mon, Jan 18, 2021 at 07:22:21PM +0000, Matt Kowlaczyk wrote:
> Jose Valim wrote a well written blog post titled "Comparing Elixir and
> Erlang variables" [1] where he highlights the pin operator in Elixir and
> explorers some of it's benefits. He succinctly addresses the class of
> bugs of it catches and contrasts the operator with Erlang. Here is a
> short snippet,
> > In other words, so far Elixir requires you to be mindful of all later
> > code after the introduction of a variable while Erlang requires you to
> > know all previous and further code before the introduction of a
> > variable. The one benefit of Erlang so far is that the code may crash
> > explicitly on the match.
> >
> > However, things get more complicated when considering case expressions.
> >
> Thought this would provide some useful context. It would be interesting
> to see how the ideas in Jose's post reconcile under this proposed EEP. I
> have not gone through the exercise.
> [1]

As I read that blog post, most problems with the Erlang semantics that José
lists would be remedied, if Erlang should have had a mandatory syntax for
matching a variable.

Most, but not for the problems with "Numbered variables", because Erlang
does not have rebinding of variables.

> -- 
> Matt Kowalczyk


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list