[erlang-bugs] bug in erlang:size

Kostis Sagonas <>
Sat Aug 4 08:29:21 CEST 2012

On 08/03/2012 11:12 AM, Joe Armstrong wrote:
> I think this is a bug:
> $erl
> 1>  B =<<1:17>>.
> <<0,0,1:1>>
> 2>  size(B).
> 2
> B is not a binary or tuple to size(B) should give badarg

There is indeed something fishy in the above...

But IMO, size/1 is one of these functions that should be considered 
deprecated and only kept for backwards compatibility.  These days there 
exist built-in functions tuple_size/1, byte_size/1, and bit_size/1 that 
are unambiguous and more type-friendly.

I would urge Joe to avoid mentioning the existence of size/1 in the new 
edition of his book.


More information about the erlang-bugs mailing list