[erlang-questions] Parameterized module and behaviour undefined warning.
Richard Carlsson
richardc@REDACTED
Sun Jun 28 15:13:20 CEST 2009
Kenny MacDermid wrote:
> I wondering if I should be using '-behaviour()' differently for a
> parameterized module. I'm getting "Warning: behaviour ____ undefined".
>
> Here's the module that I'm using as the behaviour:
>
> -----
> -module(prmmodule, [Param1, Param2]).
>
> -export([behaviour_info/1]).
>
> behaviour_info(callbacks) ->
> [{a, 1}, {b, 1}].
> -----
The implementation of parameterized modules does not currently
know to treat behaviour_info/1 as a special "static" function,
so it will add an extra argument for the current module instance.
This causes a warning, since the compiler does not find the
expected behaviour_info/1 in prmmodule.
The workaround is to make a separate, non-parameterized module
containing as a facade to the parameterized one, and put the
behaviour declaration in that one instead.
/Richard
More information about the erlang-questions
mailing list