Reputation: 409
I know that a macro is defined as follows:
-define(Const, Replacement).
-define(Func(Var1,...,VarN), Replacement).
But how does this code with double question marks meam, and how should I understand it?
-define(Assign(Var,Exp), Var=Exp, io:format("~s = ~s -> ~p~n", [??Var, ??Exp, Var] )).
start() ->
?Assign(X, lists:sum([1, 2, 3])).
Its output reads:
X = lists : sum ( [ 1 , 2 , 3 ] ) -> 6
Upvotes: 1
Views: 80
Reputation: 409
After searching, I find it. Stringifying Macro Arguments
The construction ??Arg, where Arg is a macro argument,
will be expanded to a string containing the tokens of the argument.
This is similar to the #arg stringifying construction in C.
The feature was added in Erlang 5.0/OTP R7.
Upvotes: 2