<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">"This fills a much-needed gap."</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Erlang functions are as a rule small enough that you</div><div class="gmail_default" style="font-family:monospace,monospace">shouldn't ever shadow a variable.  One of the worst</div><div class="gmail_default" style="font-family:monospace,monospace">features of Erlang is that you can write</div><div class="gmail_default" style="font-family:monospace,monospace">   foo(X) -> fun (X) -> fun (X) -> 1 end end.</div><div class="gmail_default" style="font-family:monospace,monospace">and have three different variables all called X, and</div><div class="gmail_default" style="font-family:monospace,monospace">one of the good things about erlc is that it tells you.</div><div class="gmail_default" style="font-family:monospace,monospace">foo.erl:3: Warning: variable 'X' is unused<br>foo.erl:3: Warning: variable 'X' is unused<br>foo.erl:3: Warning: variable 'X' shadowed in 'fun'<br>foo.erl:3: Warning: variable 'X' shadowed in 'fun'</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">The very last thing we want is a notation that lets</div><div class="gmail_default" style="font-family:monospace,monospace">us have two different variables with the same name</div><div class="gmail_default" style="font-family:monospace,monospace">in a single pattern.<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 25 Dec 2020 at 09:10, Richard Carlsson <<a href="mailto:carlsson.richard@gmail.com">carlsson.richard@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">The ^ operator allows you to annotate already-bound pattern variables as ^X, like in Elixir. This is less error prone when code is being refactored and moved around so that variables previously new in a pattern may become bound, or vice versa, and makes it easier for the reader to see the intent of the code.<div><br></div><div>See also <a href="https://github.com/erlang/otp/pull/2951" target="_blank">https://github.com/erlang/otp/pull/2951</a><br clear="all"><div><div dir="ltr"><br></div><div>Ho ho ho,</div><div dir="ltr"><br>        /Richard & the good folks at WhatsApp</div></div></div></div>
</blockquote></div>