mirror of
https://github.com/valitydev/parse_trans.git
synced 2024-11-06 00:25:16 +00:00
ae7163f3db
See examples/pmod.erl and examples/ex_pmod.erl This works similarly to OTP's parameterized modules, which they are now saying that they will drop. Since they drop the compiler support, a slightly different notation is needed. -pmod_vars([V1, V2, ...]). % defines the 'global' variables. -pmod_funs([F1/A1, ...]). % defines which functions are to be exported. The functions listed in -pmod_funs/1 are transformed to take an extra argument, and a new(V1, V2, ...) function is added and exported. Example: Eshell V5.9 (abort with ^G) 1> c(ex_pmod). {ok,ex_pmod} 2> M = ex_pmod:new(a,b). {ex_pmod,{a,b}} 3> M:b(x,y). {x,y,a,b}
15 lines
151 B
Erlang
15 lines
151 B
Erlang
-module(ex_pmod).
|
|
|
|
-compile({parse_transform, pmod}).
|
|
|
|
-pmod_vars(['A', 'B']).
|
|
|
|
-pmod_funs([a/1,
|
|
b/2]).
|
|
|
|
a(X) ->
|
|
X.
|
|
|
|
b(X,Y) ->
|
|
{X,Y,A,B}.
|