[erlang-questions] encapsulating types and dialyzer

Tobias Lindahl tobias.lindahl@REDACTED
Fri Sep 12 09:13:45 CEST 2008


Kostis Sagonas wrote:
> Anthony Shipman wrote:
>> Suppose I have a module MC that implements a collection type known as coll(). 
>> Internally this is some record that I want to be private to the module.
>>
>> The external functions in the interface mention the type coll(). So the 
>> clients of the interface must also mention coll() if dialyzer is to check the 
>> types.
>>
>> As far as I can see the only way to do this is to put the coll() type into 
>> a .hrl file. This exposes the record definition, and recursively every other 
>> type that it depends on.
>>
>> Is there a better way to do this? 
> 
> In the HiPE group, we have had extensive discussions about this issue. 
> The solution we came up with is to allow module-qualified types, as in 
> mc:col(), which can then be used in other modules.  This works in R12B-4 
> but not in any previous version.
> 
> Currently, all types defined in a module are also implicitly exported -- 
> this might change in a future version and modules might need to declare 
> their exported types.
> 
> Kostis
> 
> PS. I should point out that the language of types and -spec declarations
>      is currently an EEP.  Officially, it is not part of Erlang yet.

As Kostis points out, you are allowed to declare these remote types, but 
  currently they are not used. Of course, this will change in the future.

Tobias



> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list