zero length segments!

Bjorn Gustavsson bjorn@REDACTED
Wed Sep 25 10:25:57 CEST 2002


It is an old bug that the shell allows some bit syntax expressions that
the compiler doesn't allow.

In the upcoming R9 release, the shell evalulator has been corrected.

/Bjorn

"Happi" <happi@REDACTED> writes:

> The bitsize can not be an arbitrary expression, just bind the size before
> the match:
> 
> t(Bit) when integer(Bit) ->
>   S = (31 - Bit),
>    <<_:S, Flag:1, _:(Bit)>> = <<1:32>>,
>    Flag.
> 
> ----- Original Message -----
> From: "Vance Shipley" <vances@REDACTED>
> To: <erlang-questions@REDACTED>
> Sent: Tuesday, September 24, 2002 4:02 PM
> 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.
> > #Fun<erl_eval.5.63972567>
> > 2> T(0).
> > 1
> > 3> T(1).
> > 0
> >
> > -module(t).
> > -export([t/1]).
> >
> > t(Bit) when integer(Bit) ->
> >    <<_:(31 - Bit), Flag:1, _:(Bit)>> = <<1:32>>,
> >    Flag.
> >
> > 1> c(t).
> > ./t.erl:5: illegal bit size
> > error
> >
> >
> > The problem seems to be with the expression (31 - Bit).
> >
> > Any idea how to get past this?
> >
> > -Vance

-- 
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