Binary pattern syntax anomaly
Bjorn Gustavsson
bjorn@REDACTED
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.)
/Bjorn
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?
>
> Kostis.
>
--
Björn Gustavsson Ericsson Utvecklings AB
bjorn@REDACTED ÄT2/UAB/F/P
BOX 1505
+46 8 727 56 87 125 25 Älvsjö
More information about the erlang-questions
mailing list