zero length segments!
Tue Sep 24 16:35:14 CEST 2002
I've had the same problem. You have to do
Var = 31 - Bit,
<<_:Var, Flag:1, _:(Bit)>> = <<1:32>>,
From: Vance Shipley [mailto:]
Sent: 24 September 2002 15:03
Subject: Re: zero length segments!
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
NOTICE AND DISCLAIMER:
This email (including attachments) is confidential. If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents. We cannot accept liability for any breaches of
confidence arising through use of email. Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions. We will not accept responsibility for any commitments
made by our employees outside the scope of our business. We do not warrant
the accuracy or completeness of such information.
More information about the erlang-questions