# from David Nicol
# on Tuesday 07 December 2010 14:12:

>on_connect => $cb->($handle, $host, $port, $retry->())

This is confusing.  If you're going to illustrate how it is called, take 
it out of the context of how it is declared.

  on_connect => sub {
    my ($handle, $host, $port, $retry) = @;
    ...
  }

As for illustrating "I will pass you a subref here", I would say:

  $on_connect->($handle, $host, $port, sub {...})

or:

  $on_connect->($handle, $host, $port, \&retry);

or even just:

  $on_connect->($handle, $host, $port, $retry_hook);

But in this particular case, something like a "connection" object with 
handle(), host(), and port() methods seems more appropriate, which then 
would allow one to do something like '$c->retry until $c->connected' 
(assuming appropriate error handling semantics.)

Alternatively, perhaps the last parameter should be an object where one 
would say 'return $knob->retry' and this would result in the on_connect 
hook being called again after the next connection was established.

If you can, avoid the need to document "I will pass a callback to your 
callback".

--Eric
-- 
Entia non sunt multiplicanda praeter necessitatem.
--Occam's Razor
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to