[erlang-questions] variable unsafe just in macros

Lasaro <>
Mon Aug 11 00:54:21 CEST 2008


I should have saved the code around the problematic use of the macro.
If I manage to reproduce it again, I will send another message.
Thanks anyway.


On Aug 9, 11:09 pm, "litao cheng" <> wrote:
> in my computer, the two DEBUG  macro all work corretly. my erlang otp is
> R12B-3.
>
> _______________________________________________
> erlang-questions mailing list
> ://www.erlang.org/mailman/listinfo/erlang-questions
>
> 2008/8/10 Lasaro <>
>
>
>
> > 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
> > _______________________________________________
> > erlang-questions mailing list
> > 
> >http://www.erlang.org/mailman/listinfo/erlang-questions- Hide quoted text -
>
> - Show quoted text -



More information about the erlang-questions mailing list