[erlang-questions] make_ref bug or feature?

Joe Armstrong <>
Fri Mar 27 13:19:30 CET 2009


I was putting Refs into a term and then serializing them with term_to_binary
and sending them into a socket to another independent Erlang system
(ie not using distributed Erlang) - so yes it was a problem since I'd
assumed these
were unique.

/Joe

On Fri, Mar 27, 2009 at 12:57 PM, Serge Aleynikov <> wrote:
> Since a reference contains a node name, it's considered unique in a
> distributed setup when nodes have different names (or within a single
> non-distributed node).  When two shells are started this way, since they are
> not aware of each other and can't see each other's references, is it a
> problem that their values are identical?
>
> Serge
>
> Joe Armstrong wrote:
>>
>> I got a question from Ivo Danihelka about make_ref().
>>
>> Isn't make_ref() supposed to generate "an almost unique reference" the
>> manual says
>>
>>    "Returns an almost unique reference.
>>     The returned reference will re-occur after approximately 2^82
>> calls; therefore it is unique enough for practical purposes."
>>
>> If I start two erlang shells and evaluate the following in both shells:
>>
>> 1> io:format("~p~n",[term_to_binary(make_ref())]).
>>
>> <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0,
>>  0,0,34,0,0,0,0,0,0,0,0>>
>>
>> They *both* print the same thing - this violates the principle of
>> least astonishment.
>> (I thought I'd have to start 2^82 shells :-)
>>
>> Is this a bug or a feature?
>>
>> /Joe
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>



More information about the erlang-questions mailing list