announcing Smerl: Simple Erlang Metaprogramming library

Yariv Sadan yarivvv@REDACTED
Tue Aug 15 04:01:39 CEST 2006


Digging through Ulf Wiger's rdbms_codegen.erl module in Jungerl, I
discovered Erlang's wonderful capabilities for runtime code generation
and manipulation. As great as these capabilities are, I think they are
far from obvious to the non-expert programmer. That's why I created
Smerl, simple library for (runtime) Erlang metaprogramming.

To read more about Smerl and to download it, visit my blog:

Here's a direct download link:

Here's a quick example of how to use Smerl:

test_smerl() ->
  C1 = smerl:new(foo).
  {ok, C2} = smerl:add_func(C1, "bar() -> 1 + 1.").
  foo:bar().   % returns 2

Smerl also lets you work with abstract Erlang forms. The 3rd line of
the above example can be rewritten as

{ok,C2} = smerl:add_func(C1, {function,1,bar,0,

Smerl allows you to both create new module in runtime and to
manipulate existing modules by adding and removing functions.

If you have any comments, problems or suggestions, please let me know!

Best regards,

More information about the erlang-questions mailing list