[OT] Wrapping methods

Ask Bjørn Hansen ask at develooper.com
Mon Jul 6 19:50:07 BST 2009

On Jul 6, 2009, at 9:06, Nicholas Clark wrote:

> Of course this can also be solved in various other ways, such as  
> having the
> code be
>   @ISA = 'Generic::Base::ClassWithTimeout';
>   sub run_with_timeout {
>        ... # does stuff
>   }
> and Generic::Base::ClassWithTimeout having a run() method that calls
> $self->run_with_timeout(...) inside the alarmed block, but that  
> doesn't feel
> as elegant an interface.

I'm pretty sure Moose can help with this sort of thing.

I think you can get the API reasonably elegant with just clever naming  
though.  Don't make it "run_with_timeout", but "_run" (or whatever -  
something generic).   The Generic::Base::run can call that  
automatically so it'll Just Work for all the classes (with or without  

  - ask

More information about the london.pm mailing list