[erlang-questions] metaprogramming with -spec

Vlad Dumitrescu vladdu55@REDACTED
Fri Sep 19 14:52:09 CEST 2014

On Fri, Sep 19, 2014 at 2:33 PM, semmit mondo <semmitmondo@REDACTED>

> Is it possible to figure out the spec of functions in a compiled module?
> Given a module name I want to be able to know what is the return type
> of a function in that module and what are the types of the arguments.
> But all I know at the moment is the arity of the function (via
> module_info).
> Is that info lost when compiling?

If the module was compiled with debug info, then you can call
beam_lib:chunks(Module, [abstract_code]) and traverse the result looking
for the spec attributes.

I would have expected that the specs would be listed in the 'attributes'
chunk, but it looks that they aren't. Is there a reason for that?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140919/7d0e96df/attachment.htm>

More information about the erlang-questions mailing list