Evaluating code snippets

Vlad Dumitrescu <>
Mon May 16 13:33:58 CEST 2005


Hi,

I have a need to evaluate code snippets, kind of a scripting language, and I'm not sure what is the best way to do it.

The snippets are defining and using common variables, but I need to keep them separate (as opposed to compiling the whole file into a module, like for example .yaws files).

I see two alternatives:
    - save the source and evaluate it using erl_eval, and keeping the variable bindings global
    - "bake" them inside a template function that will take care of the bindings.

I would prefer the second approach, because the snippets will be called many times, but I have a problem: is there a way to retrieve the set of current bindings? I couldn't find anything, and I 'm not even sure it is possible to add such a BIF without confusing the compiler, but I thought I'd ask anyway because maybe some other idea might come up.

Thanks in advance! Regards,
Vlad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050516/6ca7f2ea/attachment.html>


More information about the erlang-questions mailing list