[erlang-questions] variable unsafe just in macros
Lasaro
lasaro@REDACTED
Sat Aug 9 23:31:45 CEST 2008
Sorry, I sent the message before it was ready (twice!). The question
was
why does this definition gives me a "variable 'Param' unsafe in
'case'".
-define(debug,true).
-ifdef(debug).
-define(DEBUG(Msg),
case Msg of
[] ->
io:format("{~p@~p:~p}", [?MODULE,?LINE,self()]);
[[_|_]=Format, [_|_]=Param] ->
io:format(lists:append(["{~p@~p:~p} ",Format]), [?MODULE,?
LINE,self()|Param]);
[_|_] ->
io:format("{~p@~p:~p} "++Msg, [?MODULE,?LINE,self()]);
_ ->
io:format("{~p@~p:~p} wrong debug call", [?MODULE,?
LINE,self()])
end).
-else.
-define(DEBUG(_M), true).
-endif.
but this one does not?
-define(debug,true).
-ifdef(debug).
deb(Msg)->
case Msg of
[] ->
io:format("{~p@~p:~p}", [?MODULE,?LINE,self()]);
[[_|_]=Format, [_|_]=Param] ->
io:format(lists:append(["{~p@~p:~p} ",Format]), [?MODULE,?
LINE,self()|Param]);
[_|_] ->
io:format("{~p@~p:~p} "++Msg, [?MODULE,?LINE,self()]);
_ ->
io:format("{~p@~p:~p} wrong debug call", [?MODULE,?
LINE,self()])
end.
-define(DEBUG(Msg), deb(Msg)).
-else.
-define(DEBUG(_M), true).
-endif.
Cheers.
Lásaro
More information about the erlang-questions
mailing list