[erlang-questions] [Dialyser] Type parametrized behaviours
Thu Apr 26 10:38:42 CEST 2012
> Note that "ugly" is a subjective word. I guess that qualifying it with
> "very" makes it... very subjective ;)
I'd say that it's equally subjective :)
I'd also say that we can agree that that in software engineering there
is a certain agreement that code duplication is bad, and in this
instance this duplication can easily be avoided.
> I am not sure what your point is. Just because this is something you
> (and perhaps many others, myself included) do not do that often, does
> not mean that Erlang does not need a mechanism that is general enough to
> allow them to do it, if they want/need to.
Well, I think then a good principle when designing a language (and many
other thins, I guess) is to try to keep things simple by satisfying a
majority, but not everyone. Apart from that, I don't think that this
specific feature of -callback is bad, mine was just an observation.
> All I tried to argue in that part of my post is that the distinction
> between specifications of allowed callbacks (-callback attributes in the
> behaviour module) and actual implementations of these callbacks (-spec
> attributes in the callback module) is a general enough mechanism that
> serves this purpose. I am sorry if you find it very ugly in your
> particular situation.
Note that in the end we decided not to narrow the types in the single
behaviours, since in our opinion it wasn't worth it. Imo parametrising
behaviours would be an elegant solution that would make narrowing the
types adequately easy and would be general enough in the vast majority
of use cases.
> Perhaps others may find it ugly if Erlang gets
> extended with both a general and some less general mechanism to solve
> the same problem depending on the situation. Think about it...
I think it could be an extremely non-invasive feature. One way it could
work, syntactically, is in a similar way parametrized modules work, e.g.
introduce an (optional)
to be used in the module defining the -callbacks. Then, in the
implementing modules, one can write
No existing code would break, and users that do not want to use this
feature would never know it exists :)
More information about the erlang-questions