Binary pattern syntax anomaly
Fri Oct 17 12:19:03 CEST 2003
We rejected nested binary patterns to keep the implementation simple.
We discussed the possibibility to have the compiler automatically
flatten nested patterns, but we decided not to do it because the
semantics could be different if patterns were not aligned on byte
boundaries. (Your example pattern could be flattened without
changing the semantics.)
P.S. I have not had any free time for reading erlang-questions the
last couple of weeks. Therefore the late answer.
Kostis Sagonas <kostis@REDACTED> writes:
> Is there any particularly good reason why the following piece of
> Erlang code works correctly
> B = <<2,42>>,
> <<1, B/binary>> = <<1, <<2,42>>/binary>>.
> while the following (semantically equivalent) code
> <<1, <<2,42>>/binary>> = <<1, <<2,42>>/binary>>.
> gets rejected as an illegal pattern?
> Isn't this a bug, or at least a totally unnecessary restriction
> in the syntax of binary patterns?
Björn Gustavsson Ericsson Utvecklings AB
+46 8 727 56 87 125 25 Älvsjö
More information about the erlang-questions