thx a lot...works now!<br>Pieter<br><br><div><span class="gmail_quote">On 5/8/08, <b class="gmail_sendername">Kostis Sagonas</b> <<a href="mailto:kostis@cs.ntua.gr">kostis@cs.ntua.gr</a>> wrote:</span><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
Pieter Erlang wrote:<br><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
<span class="q"> Hi,<br><br> Can someone explain why line 2 fails (and line 3 not)?<br> (also reproducible in other ways)<br><br><br></span><span class="q"> Erlang (BEAM) emulator version 5.6.2 [async-threads:0]<br><br> Eshell V5.6.2 (abort with ^G)<br>
 1> B = <<0:1000>>.<br> <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br> 0,...>><br> 2> <<_:80,Val:2,_/binary>> = B.<br> ** exception error: no match of right hand side value<br>
 <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br> 0,...>><br></span></blockquote><br> Till a point, Erlang supported only binaries == sequences of bytes.<br> Till then, the type qualifier that was to be used for matching against a  sequence of bytes was "binary".<br>
<br> Starting with R12, this type qualifier has been properly renamed "bytes" (but "binary" has been maintained for backwards compatibility reasons) so that programmers like Pieter Erlang are less likely to be confused by matching failures:<br>
<br> -------------------------------------------------------------------------<br> Eshell V5.6.3  (abort with ^G)<span class="q"><br> 1> B = <<0:1000>>.<br> <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br>
   0,...>><br> 2> <<_:80,Val:2,_/binary>> = B.<br> ** exception error: no match of right hand side value <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br>                                                         0,...>><br>
</span> 3> <<_:80,Val:2,_/bytes>> = B.<span class="q"><br> ** exception error: no match of right hand side value <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br>                                                         0,...>><br>
</span> -------------------------------------------------------------------------<br><br> I would strongly recommend that programs using "binary" get changed to "bytes".<br><br> If one really wants bit level pattern matching, the qualifier "bits" has been added for that purpose:<br>
<br> -------------------------------------------------------------------------<br> 4> <<_:80,Val:2,_/bits>> = B.<span class="q"><br> <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br>   0,...>><br>
</span> 5> <<_:13,Val:69,_/bits>> = B.<span class="q"><br> <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,<br>   0,...>><br></span> -------------------------------------------------------------------------<br>
<span class="sg"><br><br> Kostis<br></span></blockquote></div><br>