[erlang-questions] Re: implementing annotation in erlang

Wojciech Kaczmarek kaczmarek.w@REDACTED
Fri Sep 11 18:37:17 CEST 2009

Hi Paweł!

2009/9/9 paweł kamiński <kamiseq@REDACTED>:
> hi,
> finally I went through parse_transform but constructing even simple format
> from scratch is a nightmare.
> 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

Whenever somebody tries to use parse_transform to implement some
problem which sounds easy (but then the complexity explodes), I tend
to immediately think about LFE - Lisp Flavoured Erlang. It worked for
me many times and I didn't have to bother with parse_transforms.

So, in LFE you could define a simple macro which would run your code
at compile time when you define a function. Eg. macro could add
function name to a well known ets.

It would be easy for you to do if you were exposed to any Lisp
already. If not, that's another paradigm shift to handle.

> 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.

Erlang runtime is very simple and there you have only compiled modules
containing functions. Even the presence of variable bindings in a
shell is a hack.
As it may seem constraining for coders coming from other languages,
such simplicity makes robustness more easy.


More information about the erlang-questions mailing list