[erlang-questions] wierd "function not used" problem - code included

Edwin Fine erlang-questions_efine@REDACTED
Sun Oct 5 22:02:02 CEST 2008


Well, there are a couple of problems, but the reason why you get that warning
is that you have to export a function that you spawn_link to using
Module/Func/Args syntax, otherwise you would have to

Handler_process = spawn_link(fun() -> data_process(Socket, []) end),

The other problem is that your fun Listen_for_errors may as well be inline,
i.e. you could change this code:

   %-----------------------------------------------
   Listen_for_errors =
   fun() ->
           io:format("listening started~n"),
           receive
               {'EXIT', Pid, Why} ->
                   io:format("~p exited because:~p", [Pid,Why]);
               Other                 ->
                   io:format("Other:~p~n", [Other])
           end
   end,
   Listen_for_errors(),
    %-----------------------------------------------

    Handler_process = spawn_link(?MODULE, data_process, [Socket, []]),

To this:

    %-----------------------------------------------
    io:format("listening started~n"),
    receive
        {'EXIT', Pid, Why} ->
            io:format("~p exited because:~p", [Pid,Why]);
        Other                 ->
            io:format("Other:~p~n", [Other])
    end,
    %-----------------------------------------------

    Handler_process = spawn_link(?MODULE, data_process, [Socket, []]),


-- 
View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19828568.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list