simple proc_lib test example

Helmut Enck-Radana <>
Wed Jul 26 12:06:41 CEST 2006


At 11:34 2006-07-26, jm wrote:
>-module(test_proc).
>
>-export([go/0]).
>
>go() ->
>   proc_lib:start_link(?MODULE, simple, [], infinity).
>
>simple() ->
>   proc_lib:init_ack({ok, self()}),
>   await().
>
>await() ->
>   receive
>     after 1000 ->
>       exit({ok, timeout})
>    end.
>
>
>$ erlc test_proc.erl
>./test_proc.erl:21: Warning: function await/0 is unused
>./test_proc.erl:21: Warning: function simple/0 is unused
>
>It doesn't look good at this stage. Why does it say unused? await/0 
>is call from simple and simple/0 from proc_lib:start_link.

simple/0 is neither exported nor called by any used function in this 
module. So it is unused.

>$ erl
>Erlang (BEAM) emulator version 5.4.8 [source] [hipe]
>
>Eshell V5.4.8  (abort with ^G)
>1> test_proc:go().
>** exited: {undef,[{test_proc,simple,[]},{proc_lib,init_p,5}]} **

Since simple/0 isn't exported, it isn't visible to functions which 
are not defined within your module.

-- Helmut




More information about the erlang-questions mailing list