binary expression with fixed and variablefields

Steve Davis steven.charles.davis@REDACTED
Fri Jul 2 02:58:34 CEST 2010


On a related note, I find it curious that there's the following
limitation forcing you to manually calculate the size of an already
known binary:

1> <<"a", _/binary>> = <<"abc">>.
<<"abc">>
2> A = <<"a">>.
<<"a">>
3> ABC = <<"abc">>.
<<"abc">>
4> <<A, _/binary>> = ABC.
** exception error: no match of right hand side value <<"abc">>
5> Size = size(A).
1
6> <<A:Size/binary, _/binary>> = ABC.
<<"abc">>

...a minor inconvenience, but irritating.

Perhaps there's a reason that I don't immediately see why 4> isn't
valid?

/s


More information about the erlang-questions mailing list