[erlang-questions] Re: implementing annotation in erlang

paweł kamiński kamiseq@REDACTED
Wed Sep 9 23:51:39 CEST 2009


hi,
finally I went through parse_transform but constructing even simple format
from scratch is a nightmare.

to prepare something like
cmdCallbackList()->
[{"cmdDevSetTime",setTime,1},{"cmdFpSetStatus",setStatus,2}].

I need to build
{function,19,cmdCallbackList,0,
     [{clause,19,[],[],
          [{cons,20,
               {tuple,20,
                   [{atom,20,"cmdDevSetTime"},
                    {atom,20,setTime},
                    {integer,20,1}]},
               {cons,20,
                   {tuple,20,
                       [{atom,20,"cmdFpSetStatus"},
                        {atom,20,setStatus},
                        {integer,20,2}]},
                   {nil,20}}}]}]}

is there a way to construct code blocks in more elegant way, something like
create_fun(LineNo, Name, Arity, Body, ..)-> would produce function block
create_tuple(LineNo, Tuple)
create_list(...)
and so on

and still Im thinking that extracting information from code in runtime is
far more productive (elegant, sufficient, just simpler) then transforming
code to something different. generally all I need is just to obtain
information that this function is annoted with metadata and store that or
make additional tasks. with parse transform I need to build and add new
function to parsed module that other can call and get those information or
create whole new file with well known name that other modules could refer
to.

anyway thanks for help

pozdrawiam
Paweł Kamiński

kamiseq@REDACTED
pkaminski.prv@REDACTED
______________________


More information about the erlang-questions mailing list