<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Kostis,</div><div><br></div><div>Perhaps you could ponder how e.g. the function gen_server:enter_loop/[3,4,5] works in the context of callback specs.</div><div><br></div><div>One of the reasons for having this function is to be able to send an explicit ack from the init callback, and then continue with a blocking operation [1]. One can then call gen_server:enter_loop() to give control to the main loop. However, this function doesn't return, so it seems to violate the behavior specs.</div><div><br></div><div>I would like to see an extended return value from init, e.g. {cont, Cont, State}, along the lines of </div><div><br></div><div><div> case catch Mod:init(Args) of</div><div> {cont, Cont, State} -></div><div> proc_lib:init_ack(Starter, {ok, self()}), </div><div> NewState = Cont(State),</div><div> loop(Parent, Name, NewState, Mod, infinity, Debug);</div></div><div> …</div><div> end</div><div><br></div><div>This seems more regular from a typing point of view.</div><div><br></div><div>BR,</div><div>Ulf W</div><div><br></div><div>[1] See e.g. <a href="http://groups.google.com/group/erlang-programming/browse_thread/thread/70209d4c2bf2dac3/8c85937c309ab81b?lnk=gst&q=enter_loop+ulf#8c85937c309ab81b">http://groups.google.com/group/erlang-programming/browse_thread/thread/70209d4c2bf2dac3/8c85937c309ab81b?lnk=gst&q=enter_loop+ulf#8c85937c309ab81b</a></div><br><div><div>On 6 Dec 2011, at 12:28, Kostis Sagonas wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 12/06/2011 12:04 PM, Andrzej Sliwa wrote:<br><blockquote type="cite">Hi,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">do you know guys where I can find -specs for application and other OTP<br></blockquote><blockquote type="cite">behaviors (I mean callbacks & api specifications)?<br></blockquote><blockquote type="cite">this is weird that we see on many presentations about start using specs<br></blockquote><blockquote type="cite">in modern erlang code, but there is no specs in OTP behaviors :D<br></blockquote><br>Callback specs for OTP behaviours is a language addition that will appear in the upcoming R15 release (scheduled for mid December).<br><br>There is a new attribute called -callback that specifies types that behaviour callbacks are supposed to have. Given such information, one does not need to specify a behaviour_info/1 function anymore (at least as far as callbacks are concerned) since the compiler has been adapted to automatically generate this function. In addition, the dialyzer tool has been adapted to check behaviours.<br><br>As I wrote, this is coming in an OTP near you really soon now. In the meantime, if you are interested in this you can get a copy of the pre-release of R15 (from github) and see all behaviour modules containing such callback attributes and/or read the following paper:<br><br><span class="Apple-tab-span" style="white-space:pre"> </span>Typed callbacks for more robust behaviours<br><span class="Apple-tab-span" style="white-space:pre"> </span><a href="http://dl.acm.org/citation.cfm?id=2034660">http://dl.acm.org/citation.cfm?id=2034660</a><br><br>Kostis<br>_______________________________________________<br>erlang-questions mailing list<br>erlang-questions@erlang.org<br>http://erlang.org/mailman/listinfo/erlang-questions<br></div></blockquote></div><br></body></html>