[erlang-questions] idea: function meta data

Chandru chandrashekhar.mullaparthi@REDACTED
Thu Nov 15 12:23:05 CET 2007


On 15/11/2007, Joe Armstrong <erlang@REDACTED> wrote:
> Module have metadata  Mod:module_info(export) etc.
>
> But functions do not.
>
> idea - attach function meta data with a new attribute.
>
>      -meta(doc, "the factorial function").
>      -meta(type, "int -> int").
>      -meta(keywords, [math]).
>
>      fac(0) -> 1;
>      fac(N) -> N*fac(N-1)
>
> The meta data gets *attached* to the Next function in the module
>
>     -meta(process, true).
>     foo() -> spawn(fun() -> ... end)
>
> After compilation meta data can be access as follows:
>
>    Mod:meta_data(fac, 1, doc) => "the factorial function"

I think this will be really useful. I've always wanted a way to
provide help for functions but that usually involves either writing a
function such as <function>_usage()/0 or <function>_help() and hard to
standardise upon.

cheers
Chandru



More information about the erlang-questions mailing list