Meta-Erlang (was RE: Erlang vs Java revisited)
Vlad Dumitrescu
vlad_dumitrescu@REDACTED
Wed Sep 28 19:10:37 CEST 2005
Hi,
----- Original Message -----
From: "Ulf Wiger (AL/EAB)" <ulf.wiger@REDACTED>
> One of the annoying things about parse transforms is that
> you tend to have to cover the entire language even if you
> just want to add a small tweak.
Yes, I know, I tried it myself.
That's why I think that it would be interesting to explore how it would work
to be able to embed this into the language proper (or more precisely, its
meta-variant).
Example, a simple parse transform could look like this (just a rough
sketch):
ParseTransform = meta:define(
fun(F, A) ->
io:format("start fun ~p(~p)", [P, A]),
Result = apply(meta:splice(F), meta:splice(A)),
io:format("returns ~p", [Result]),
Result
end
)
where
meta:define() returns the abstract code for the argument
meta:splice() inserts the arguments' value in the current abstract code
tree
Then by defining
-apply_parse_transform(ParseTransform, foo/2).
this parse transform would be applied in the compiled code.
Much simpler, right?
regards,
Vlad
More information about the erlang-questions
mailing list