[erlang-questions] Erlang 19 callbacks aren't attributes?

Björn Gustavsson <>
Mon Jan 23 13:28:49 CET 2017


On Mon, Jan 16, 2017 at 8:08 PM, Ryan Stewart <> wrote:
> There was a question about this on the list a few months back, but it was
> unanswered. It seems that in Erlang 19, a module's callbacks no longer
> appear in the module_info() as 'attributes'. They are, however, included in
> the abstract code (via beam_lib). I'm wondering if this was an intentional
> change or an oversight.

The change was intentional, but we did not foresee that it would
cause problems.

There is no formal documentation exactly which attributes should
appear in module_info(attributes). A long time ago, all attributes
except 'module', 'export', 'import', 'file', and 'record' were included.

When the dialyzer attributes 'type', 'spec', and 'opaque' were introduced
we decided not to include them to reduce the code size.

Since 'callback' and 'optional_callback' are attributes that
are used by dialyzer, we decided that they too should be
excluded (for consistency).


I don't know exactly what information meck needs,
but there is the behaviour_info/1 function can be used
to retrieve the names of callback functions. See:

http://erlang.org/doc/design_principles/spec_proc.html#id81417

If the meck will need the complete spec, the solution for now
at least is to extract from the abstract code.

/Bjorn


-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list