[erlang-questions] Simple OTP Question...

David Lloyd lloy0076@REDACTED
Wed Oct 1 04:58:38 CEST 2008


Hi There,

My source is:

-module(ping).
-behaviour(gen_server).

-export([init/1, terminate/2, code_change/3]).
-export([handle_call/3, handle_cast/2, handle_info/2]).

init(Args) ->
     {ok, "Started"}.

handle_call(Request, From, State) ->
     true,
     {reply, "Pong", State}.

handle_cast(Request, State) ->
     {stop, "Not implemented", State}.

handle_info(Info, State) ->
     {stop, "Not implemented", State}.

terminate(Reason, State) ->
     true.

code_change(OldVsn, State, Extra) ->
     State.


bash-3.00$ erl
Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] 
[kernel-poll:false]

Eshell V5.5.5  (abort with ^G)
1> c(ping).
./ping.erl:7: Warning: variable 'Args' is unused
./ping.erl:10: Warning: variable 'From' is unused
./ping.erl:10: Warning: variable 'Request' is unused
./ping.erl:14: Warning: variable 'Request' is unused
./ping.erl:17: Warning: variable 'Info' is unused
./ping.erl:20: Warning: variable 'Reason' is unused
./ping.erl:20: Warning: variable 'State' is unused
./ping.erl:23: Warning: variable 'Extra' is unused
./ping.erl:23: Warning: variable 'OldVsn' is unused
{ok,ping}
2> gen_server:start({ok, pserv}, ping, {args}, []).

=ERROR REPORT==== 1-Oct-2008::12:23:47 ===
Error in process <0.30.0> with exit value: 
{function_clause,[{gen,where,[{ok,pserv}]},{gen,start,6},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}

** exited: {undef,[{shell_default,handle_call,[1,2,3]},
                    {erl_eval,do_apply,5},
                    {shell,exprs,6},
                    {shell,eval_loop,3}]} **

However, if I remove the "true, " in the source, the gen_server starts.

I can't figure out what's causing this behaviour and I'm looking at the 
STDLIB documents and Programming Erlan.

DSL




More information about the erlang-questions mailing list