[erlang-questions] in-flight module transforms - request for comments
Tue Oct 18 13:12:40 CEST 2011
On 18 Oct 2011, at 12:06, Ulf Wiger wrote:
> From those of you who enjoy modifying existing code at run-time, I would like to ask for some input.
> Inspired by Joe Norton's use of Meck to introduce support for asciiedoc syntax in EDoc , I started playing with Meck to do similar things with e.g. tweaking epp on the fly for alternative syntax support.
So, just to illustrate what tweaking epp could look like:
Say I want to abbreviate the Erlang fun … end syntax, using something shorter:
lists:map(`(X) -> X*2`, L).
A sample shell dialogue:
Eshell V5.8.4 (abort with ^G)
./toker_test.erl:5: syntax error before: '`'
./toker_test.erl:8: syntax error before: '`'
./toker_test.erl:2: function double/1 undefined
./toker_test.erl:2: function i2l/1 undefined
The actual tweak is almost exactly like the example I showed earlier, but replacing epp:parse_erl_form/1 with a version that calls my own, modified version of erl_parse. The other thing needed is to export epp:epp_request/2.
Not that I'm recommending doing this for real! ;-)
Ulf Wiger, CTO, Erlang Solutions, Ltd.
More information about the erlang-questions