Subject: [erlang-questions] Should erlang have macro
FUNCTION_ARGS ?



Hi mail-list:

We have FUNCTION_NAME and FUNCTION_ARITY in OTP 19+.

Is there FUNCTION_ARGS to get the argument list in current functions?

For example:

a_function(X, Y) ->
?FUNCTION_ARGS.

After preprocessing, the example will look like:

a_function(X, Y) ->
[X, Y].

Using this macro, we can use erlang:apply(fun
?FUNCTION_NAME/?FUNCTION_ARITY, ?FUNCTION_ARGS) to make any function
recursively.

For example:
-define(RECURSIVE_FUNCION, erlang:apply(fun
?FUNCTION_NAME/?FUNCTION_ARITY, ?FUNCTION_ARGS)).

b_function(A) ->
do_something(),
?RECURSIVE_FUNCION.

After preprocessing, the example will look like:

b_function(A) ->
do_something(),
erlang:apply(fun b_function/1, [A]).

Using this macro, we can use io:format("~p", [FUNCTION_ARGS]) to print
arguments in any function.

For example:

-define(PRINT_ARGS, io:format("~p", [FUNCTION_ARGS])).

c_function(A) ->
PRINT_ARGS,
do_something(A).


After preprocessing, the example will look like:

b_function(A) ->
io:format("~p", [A]),
erlang:apply(fun b_function/1, [A]).
_______________________________________________
erlang-questions mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-questions

...



Programming list archiving by: Enterprise Git Hosting