[erlang-questions] Generating exprs on the fly

Pierre Fenoll pierrefenoll@REDACTED
Wed Aug 14 15:27:32 CEST 2013


Tools dedicated to generate Erlang code are the erl_{scan,parse,syntax} and
compile modules.
However, in order to build and load code at runtime one is forced to put
one's code into a module and then an exported function.

Is it not possible to build and load small pieces of code, such as fun
expressions or a list of atoms, without the constraint of being inside a
thus generated module/exported function?

I imagine it must go against some Erlang rules (wouldn't it be considered
global state?),
but it somehow feels cleaner than to have to generate a module and export a
function just to access runtime-variable code.

(What I am actually doing is scanning & parsing a "query string" then
building a list comprehension out of it, then executing the LC. Thus the
need for a runtime-generated fun-expr).

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

More information about the erlang-questions mailing list