[erlang-questions] Re: Using -spec for callbacks when defining behaviours
Ulf Wiger
ulf.wiger@REDACTED
Wed Mar 17 18:17:41 CET 2010
On Wed, 17 Mar 2010 17:26:38 +0100, Magnus Henoch
<magnus@REDACTED> wrote:
> How about using a separate clause of the behaviour_info function for
> type specs? Like this:
>
> %% foo.erl
> -module(foo).
> -compile(export_all).
>
> behaviour_info(callbacks_with_types) ->
> [{foo, 1, "-spec foo(A) -> A."},
> {bar, 0, "-spec bar() -> 'ok'."}];
> behaviour_info(callbacks) ->
> [{F,A} || {F,A,_Spec} <- behaviour_info(callbacks_with_types)].
>
Perhaps the clause could rather be
behaviour_info(specification) ->
[{foo, 1, "-spec foo(A) -> A."}, ...].
The behaviour_info(callbacks) clause would only be needed
for backwards compatibility.
BR,
Ulf
--
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
More information about the erlang-questions
mailing list