Doc or gen_event:notify/2 Error!

Martin J. Logan mlogan@REDACTED
Wed Sep 10 18:45:47 CEST 2003


I think that a "call" should crash if there is a timeout - let it die
unless you catch the error for some reason. Calls with a timeout are
necessarily synchronous. I am just wondering if asynchronous casts and
messages should have the same behaviour. Should an unregistered_name !
msg really cause an exit? Is this something to "let it die" over? Is not
the true spirit of asynchronous messaging just send and pray? 

Martin

 
On Wed, 2003-09-10 at 10:51, Lennart Öhman wrote:
> Hi,
> not claiming to have the perfect answer or solution but. Many other
> OTP client/server functions crash if something goes wrong. For instance
> if you have a time-out on a call.
> 
> Then there is already a difference in the behaviour in Erlang between
> sending to a non existing PID and a non existing name. The first is
> legal but the second causes a run-time error. One can then argue that
> the call function shall follow this anomaly since it is what an Erlang
> programmer may expect.
> 
> /Lennart
> 
> Martin J. Logan wrote:
> 
> > I will catch the error then. I think that having to take measures to
> > avoid a crash produced by my asynchronous call seems to run counter to
> > the spirit of asynchronous communication. Though I could be missing some
> > overriding reason to let it exit. 
> > 
> > 
> > On Wed, 2003-09-10 at 01:08, Gunilla Arendt wrote:
> > 
> >>Snip from the gen_event man page:
> >>
> >>"Unless otherwise stated, all functions in this  module  fail
> >> if  the  specified  event  manager  does not exist or if bad
> >> arguments are given"
> >>
> >>The same goes for gen_server and gen_fsm.
> >>
> >>Regards, Gunilla
> >>
> >>"Martin J. Logan" wrote:
> >>
> >>>Hello,
> >>>   I have found an inconsistency in the docs.
> >>>
> >>>The docs indicate that the return value for gen_event notify is as
> >>>follows:
> >>>
> >>>notify(EventMgrRef, Event) -> ok
> >>>
> >>>This makes sense as it is asynchronous. I pass a registered name to a
> >>>notify call and if the name is not registered I get an exit(). It is the
> >>>same badarg exit that one would expect from
> >>>
> >>>unregistered_name ! message
> >>>
> >>>I think that either the docs should be changed to
> >>>
> >>>notify(EventMgrRef, Event) -> ok | exit()
> >>>
> >>>or more preferably the notify/2 function should not exit.
> >>>
> >>>Cheers,
> >>>Martin
> >>>
> >>>OUTPUT:
> >>>
> >>>gen_event:notify(martin, martin).
> >>>
> >>>=ERROR REPORT==== 9-Sep-2003::17:05:56 ===
> >>>Error in process <0.31.0> with exit value:
> >>>{badarg,[{gen_event,send,2},{erl_eval,do_apply,5},{shell,eval_loop,2}]}
> >>>
> >>>** exited: {badarg,[{gen_event,send,2},
> >>>                    {erl_eval,do_apply,5},
> >>>                    {shell,eval_loop,2}]} **
> > 
> > 




More information about the erlang-questions mailing list