[erlang-questions] Specs for optional callbacks (try 2)
Kostis Sagonas
kostis@REDACTED
Sun Sep 28 11:28:16 CEST 2014
On 09/28/2014 11:47 AM, Ulf Wiger wrote:
> The most backwards-compatible way to do this would surely be:
>
> behaviour_info(callbacks) ->
> [{foo, 2}, {bar, 4}];
> behaviour_info(optional_callbacks) ->
> [{bar, 3}, {boo, 14}];
> behaviour_info(_) ->
> undefined.
>
> Presumably, having behaviour_info/1 together with -callback specs was
> disallowed because the compiler would have to check consistency between
> them, and to partial evaluation of the behaviour_info/1 code?
No. With -callback information, the whole behaviour_info/1 function is
redundant since it can be (and is) generated automatically by the
compiler from the -callback specifications.
behaviour_info/1 is currently allowed to be present for backwards
compatibility but its support should be discouraged and discontinued.
Besides the {F,A} notation being butt ugly, behaviour modules should
really document the expected types of their callbacks, not just their arity.
Kostis
More information about the erlang-questions
mailing list