[erlang-questions] bit syntax: 0-sized segments

Kostis Sagonas <>
Thu Mar 7 14:43:05 CET 2013


In revising some HiPE test suites for bit syntax, I noticed some pattern 
matching with 0-sized segments.  They can be illustrated by the following:

Eshell V5.10.2  (abort with ^G)
1> <<X:0>> = <<>>.
<<>>
2> X.
0

I think this is interesting and some may consider the above pattern 
matching a bit weird, possibly preferring an exception instead.

The documentation is mute about the presence of these 0-sized segments:

   http://www.erlang.org/doc/reference_manual/expressions.html#bit_syntax

I think that they need to be explicitly mentioned there, possibly 
together with some rationale for their existence.

Kostis



More information about the erlang-questions mailing list