Re: New EEP draft: Pinning operator ^ in patterns
Raimo Niskanen <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <[email protected]> |
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] > http://blog.plataformatec.com.br/2016/01/comparing-elixir-and-erlang-variables/ 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