zero length segments!
Tue Sep 24 16:02:46 CEST 2002
Well didn't I speak too soon! While this works wonderfully in the shell
it won't complile. :(
Eshell V5.1.2 (abort with ^G)
1> T = fun(Bit) -> <<_:(31 - Bit), Flag:1, _:(Bit)>> = <<1:32>>, Flag end.
t(Bit) when integer(Bit) ->
<<_:(31 - Bit), Flag:1, _:(Bit)>> = <<1:32>>,
./t.erl:5: illegal bit size
The problem seems to be with the expression (31 - Bit).
Any idea how to get past this?
Motivity Telecom Inc.
+1 519 579 5816
On Tue, Sep 24, 2002 at 06:33:23AM -0400, Vance Shipley wrote:
> Was I ever happily suprised when I found that this was a valid expression:
> <<0:8, 1:24, 0:0>>
> It results in:
> The reason this is so good is that it I don't have to handle a special
> case when X=0:
> Flag = <<_:(31-X), Flag:1, _:(X)>>
> Of course I'm sure that that is why it works, I'm just very happy about it. :)
More information about the erlang-questions