> 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 [1], 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:
-module(toker_test).
-export([double/1, i2l/1]).
double(L) ->
lists:map(`(X) -> X*2`, L).
i2l(L) ->
lists:map(`integer_to_list/1, L).
A sample shell dialogue:
Eshell V5.8.4 (abort with ^G)
1> c(toker_test,[{outdir,"../ebin"}]).
./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
error
2> c(toker_c,[{outdir,"../ebin"}]).
{ok,toker_c}
3> toker_c:c(toker_test,[{outdir,"../ebin"}]).
{ok,toker_test}
4> toker_test:double([1,2,3]).
[2,4,6]
5> toker_test:i2l([1,2,3]).
["1","2","3"]
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! ;-)
BR,
Ulf W
Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
For those of you out there who have used similar things before, what kind of support would you like to see?
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! ;-)