[erlang-questions] Unique references

Vance Shipley vances@REDACTED
Fri Aug 8 18:56:31 CEST 2008


I find it odd that in the recent thread about unique references
no one has mentioned the native erlang reference data type:

  http://www.erlang.org/doc/reference_manual/data_types.html#2.5

I have heard it said that a ref() is not as sure to be unique as
it should be.  If that is the case shouldn't it be fixed?  Since
it is to be an opaque value it shouldn't break anything if it is
changed.

   (foo)1> make_ref().
   #Ref<0.0.0.32>

The documentation says:

   "A reference is a term which is unique in an Erlang runtime system"

I believe it is actually unique in a distributed Erlang system as well:

   (bar)1> global:register_name(bar, self()).
   yes

   (foo)2> global:send(bar, R).
   <5700.37.0>

   (bar)2> receive R -> R end.
   #Ref<5737.0.0.62>

The "5737" is the node part.

The problem with the ref() is that it isn't unique across instances
of an erlang runtime system:

   1> make_ref().
   #Ref<0.0.0.32>

   1> make_ref().
   #Ref<0.0.0.32>

Why don't we just fix this?

	-Vance



More information about the erlang-questions mailing list