[erlang-questions] R13B prefers reference() to ref()

Kostis Sagonas kostis@REDACTED
Wed Apr 22 19:10:26 CEST 2009


Magnus Henoch wrote:
> I found that R13B has a different opinion on the correct type name for
> references than both R12B-5 and R13A: the former accepts only
> 'reference()', while the latter accept only 'ref()'.  Is this
> intentional?  Is there a way to write a type specification that works in
> both compilers, apart from using 'any()'?
> 
> Example - this compiles with R12B-5 but doesn't compile in R13B:
> 
> -module(foo).
> -record(foo, {bar :: ref()}).
> 

Half an hour ago, I sent more or less the following answer to another 
user who asked the same thing in a private e-mail.


Sorry about this incompatibility, but it was pointed out to us that the 
use of ref() as type is inconsistent with the rest of the language (all 
primitive types, e.g. atom(), pid(), binary(), are such that they map to 
is_* guards, and there is no is_ref/1 guard, but is_reference/1).  Also, 
using ref() is inconsistent with Edoc that also uses reference().  So we 
changed this.

The best thing for users would be to just convert to using reference() 
throughout.  If one really wants to be able to compile with both R12B-5 
and R13B-*, one can add the declaration:

-type ref() :: reference().

and protect it with an appropriate -ifdef(R13B) or similar.

Kostis



More information about the erlang-questions mailing list