yeah. I see. Thank you very much Edwin.<br>my opinion: in binary syntax, the integer, float can always use their default size, but binary(bits and bytes) must declare its size specification except the very last binary element. Is't right?<br>
I come from china, so my english is not good, please don't mind my expression. :)<span class="EP8xU" style="color: rgb(121, 6, 25);"></span><br><br><div class="gmail_quote">2008/6/20 Edwin Fine <<a href="mailto:erlang-questions_efine@usa.net">erlang-questions_efine@usa.net</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">There's a subtlety here that you may have missed. The manual says<div class="Ih2E3d"><br>
<br>All other *bit string or binary*
elements in the matching must have a size specification.<br><br></div>In <<A, B, C>> = <<1,2,3>>, all elements on the left hand side are by default of type integer, not bitstring or binary. Therefore sizes are assumed to be 1 byte each. <br>
<br>Your example is the same as writing<br><br><<A/integer, B/integer, C/integer>> = <<1,2,3>>.<br><br>This below, for example, would NOT work:<br><br><<A/binary,B/binary>> = <<1,2,3>>.<br>
<br>You would have to write<br><br><<A:1/binary,B/binary>> = <<1,2,3>>.<br><br>Example:<br>1> <<A/binary,B/binary>> = <<1,2,3>>.<br>* 1: a binary field without size is only allowed at the end of a binary pattern<br>
2> <<A:1/binary,B/binary>> = <<1,2,3>>.<br><<1,2,3>><br>3> A.<br><<1>><br>4> B.<br><<2,3>><br>5> <br><br>Hope this helps.<br><div class="gmail_quote">
2008/6/19 成立涛 <<a href="mailto:litaocheng@gmail.com" target="_blank">litaocheng@gmail.com</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">In erlang reference mannual, the Bit Syntax Expressions section, about the binary Size, the manual said:<br>
"In matching, this default value is only
valid for the very last element. All other bit string or binary
elements in the matching must have a size specification."<br>we know the default size for integer is 8, float is 64, binary is the whole bytes.<br>for example:<br>> <<A, B, C>> = <<1, 2, 3>>.<br>
I think in this pattern match, the variables A, B, C all use the dafault Size.<br>Is it a conflict with reference manual?<br>thanks!<br>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>
</blockquote></div><br>