<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Is there a reference for the resolution of patterns in function/clause head similar to </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><a href="http://www.erlang.org/doc/apps/erts/match_spec.html" target="_blank" style="color:rgb(17,85,204)">http://www.erlang.org/doc/apps/erts/match_spec.html</a></div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
but for regular Erlang? The docs on the abstract format is useful</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<a href="http://www.erlang.org/doc/apps/erts/absform.html" target="_blank" style="color:rgb(17,85,204)">http://www.erlang.org/doc/apps/erts/absform.html</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">There are a few places in the docs that refer to the process of matching the function clause head against arguments</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
e.g. the function overview</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<a href="http://www.erlang.org/doc/reference_manual/functions.html#id74558" target="_blank" style="color:rgb(17,85,204)">http://www.erlang.org/doc/reference_manual/functions.html#id74558</a></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">but it would be really useful to have those references link to documentation which describes this process.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Thanks,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Erik.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">(ps - I'm happy with your answer, Björn-Egil, but hoping this thread can include some solid leads for others researching similar issues.)</div>
<div><br></div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">(pps - there is a definitive response to my original post from Björn-Egil <span style="background-color:transparent">Dahlberg below -- he inadvertently sent it directly to me)</span></div>
<div><span style="background-color:transparent"><br></span></div><div class="gmail_quote">On Fri, Oct 26, 2012 at 11:59 AM, Björn-Egil Dahlberg <span dir="ltr"><<a href="mailto:wallentin.dahlberg@gmail.com" target="_blank">wallentin.dahlberg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div class="im">2012/10/26 Erik Pearson <span dir="ltr"><<a href="mailto:erik@defunweb.com" target="_blank">erik@defunweb.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Hi,</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">


I'm wondering why this </div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<div>test(<<Field:Len/binary, Rest/binary>>, Len) -></div><div>    {Len, Field, Rest}.</div></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">does not compile, complaining that "variable 'Len' is unbound", while this</div><div><br><div><font color="#222222" face="arial, sans-serif">test(<<Field:2/binary, Rest/binary>>, Field) -></font></div>


<div><font color="#222222" face="arial, sans-serif">    {Field, Rest}.</font></div></div><div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">does. For some reason the compiler doesn't see the Len from the match spec in the arguments, but it does see Field. Is that by design?</font></div>

</blockquote><div><br></div></div><div>Yes and a limitation that is being adressed. </div><div class="im"><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">BTW  supplying a variable for Len does work in this case:</font></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">


<br></div><div><div><font color="#222222" face="arial, sans-serif">test(Bin, Len) -></font></div><div><font color="#222222" face="arial, sans-serif">  <<Field:Len/binary, Rest/binary>> = Bin, </font></div>

<div>
<font color="#222222" face="arial, sans-serif">  {Len, Field, Rest}.</font></div></div></blockquote><div><br></div></div><div>The difference here is that Len is bound when entering the function body as opposed when it is in the function head. </div>

<div><br></div><div>We have had fierce debates on, among other things, matching behaviors for Maps (extended frames/hashes) which also have led to redesigning parts how binary matching is done in function heads. This is currently in the prototyping stages and it is to early to say to which release this will be ready.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>// Björn-Egil</div></font></span></div>
</blockquote></div><br>