simple proc_lib test example
Romain Lenglet
rlenglet@REDACTED
Wed Jul 26 12:11:36 CEST 2006
jm wrote:
> Having some problems with the following program is simplified
> example based on something I'm trying to write,
>
> -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. I can understand the latter though as
> it's call from proc_lib:start_link as a parameter. Ignoring
> this and continuing....
>
> $ 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}]}
> ** 2>
>
> and this where it hits a wall. Most likely it a simple
> beginner's error. Anyone to point out the glaringly obvious to
> me?
-export([simple/0]).
This function must be exported since it is to be called from the
proc_lib module.
--
Romain LENGLET
More information about the erlang-questions
mailing list