Concerning erlang's bit syntax
Bjorn Gustavsson
bjorn@REDACTED
Tue Nov 4 14:41:31 CET 2003
Works fine for me.
Are you sure compiled the module with a R9C compiler?
(It will now work with previous releases.)
/Bjorn
Magnus Thoang <magnus.thoang@REDACTED> writes:
> Hi,
>
> I like erlang's bit syntax. It makes my life easier in almost all
> situations where I need to shuffle bytes around.
>
> I was surprised, though, when the code I had ran in the erlang shell
> had to be rewritten for the compiler:
>
> This matching works (R9C) in the shell but cannot be put in a module:
>
> <<StrSize:32,Str:StrSize/binary,Rest/binary>> =
> <<0,0,0,6,$e,$r,$l,$a,$n,$g,1,2,3,4,5,6,7,8>>
>
> When trying to compile the above expression, the compiler gives an
> error about StrSize being unbound (in the 'Str:StrSize/binary'
> expression).
>
> The documentation is not clear about this case, but it mentions a
> somewhat similar function head as not being allowed.
>
> It is just a minor annoyance, but is there a good reason for this?
>
> --
> Magnus Thoäng
>
--
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