[erlang-questions] [Dialyser] Type parametrized behaviours

Stavros Aronis aronisstav@REDACTED
Tue Apr 24 22:15:53 CEST 2012


I do not want to go much further with this, but I fail to understand what 
kind of changes would trigger this need for extensive changes. If the 
behaviour code needs to be agnostic of the type of this state variable and 
"term()" needs not be changed due to this reason. The type definitions are 
already in every module because that's where the specialization is being 
made. On the other hand, if the same type is used in many modules then it 
should be defined in the behaviour module and exported. Then it can be used 
in all of them, without any need of copying. Could you provide a more 
detailed example?

Stavros

On Tuesday, April 24, 2012 9:47:06 PM UTC+2, Francesco Mazzoli wrote:
>
> On 24/04/12 20:36, Stavros Aronis wrote:
> > In this case you can leave generic definitions in the -callback
> > attributes and write the fully specified specs in the callback module:
> >
> > %% Behaviour module:
> > ...
> > -callback step(State :: term()) -> NewState :: term().
> > ...
> >
> > %% Callback module:
> > ...
> > -type state() :: #state{}.
> > ...
> > -spec step(state()) -> state().
> > ...
>
> Yes, this works but is tedious and error prone, each time you change the 
> behaviour you have to change each implementing module.
>
> You end up manually doing something that a computer does much better 
> (copy-pasting code).
>
> Francesco.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120424/44c5b606/attachment.htm>


More information about the erlang-questions mailing list