closing the loop on Erlang metaprogramming with Smerl

Yariv Sadan yarivvv@REDACTED
Thu Aug 17 23:30:01 CEST 2006


> I think this pretty much concludes the development of Smerl. I want to
> keep Smerl simple, so any additional metaprogramming features would
> belong in higher-level libraries.
>

Boy, was I wrong!

Old way:

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

New way:

A = 7,
C1 = smerl:new(foo),
{ok, C2} = smerl:add_func(foo, bar, fun() -> 3 + A end),
smerl:compile(C2),
foo:bar(). %% returns 10

Yup, Smerl now supports fun expressions -- even closures!

http://yarivsblog.com/articles/2006/08/17/smerl-attains-erlang-metaprogramming-nirvana

Cheers,
Yariv



More information about the erlang-questions mailing list