On Fri, 2009-01-02 at 14:19 +0200, Leon Timmermans wrote:
> When going OO, I'd say an augment()/inner() approach would be
> cleanest. See
> http://search.cpan.org/~drolsky/Moose/lib/Moose/Cookbook/Basics/Recipe6.pod
> for an example. I don't know how to express that in Perl 6 though.
There's no description on that page, just sample code, but it looks like
augment performs a similar function to the .wrap method on Routines in
Perl 6. That's an interesting variation of my approach #4, I think:
> > 4. In order to keep the sub separate, but still not split the
> > pid_file_handler call, I came up with a variation of #3 in which
> > pid_file_handler takes a callback parameter:
> >
> > sub init_server {
> > # ...
> > pid_file_handler($options{pid_file}, &become_daemon);
> > # ...
> > }
> >
> > sub pid_file_handler($pid_file, &callback) {
> > # ... top half ...
> > callback();
> > # ... bottom half ...
> > }
I like your idea a little better than the callback method, because I can
see the logic behind saying I want to make an enhanced version of
become_daemon that is *also* able to handle PID files. However, it ties
the two together -- the PID file handling cannot be used in any context
other than becoming a daemon, and in particular it's not obvious how you
would unit test it.
-'f