binary expression with fixed and variablefields

Steve Davis <>
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">>.
2> A = <<"a">>.
3> ABC = <<"abc">>.
4> <<A, _/binary>> = ABC.
** exception error: no match of right hand side value <<"abc">>
5> Size = size(A).
6> <<A:Size/binary, _/binary>> = ABC.

...a minor inconvenience, but irritating.

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


More information about the erlang-questions mailing list