I want to do what the author of the original post in this thread asked for: automatically wrap all my methods with custom code. I have a module (MooseX::Params) that performs argument processing for subs via attributes, e.g.:
sub foo :Args(bar, baz) { ... } The wrapping is triggered by the application of a subroutine attribute (e.g. 'Args'). However, I would prefer an interface where the signature is specified in the prototype slot of the sub: sub foo (bar, baz) { ... } As it happens, I can do that with the warnings::illegalproto pragma, but in that case there is no event to fire the wrapping code. A hook that gets triggered after the compilation of the sub will solve this (this is the approach the signatures pragma uses). This is not strictly a Moose question, it's just that the discussion started here. Cheers, -- Peter >________________________________ > From: Chris Weyl <cw...@alumni.drew.edu> >To: Peter Shangov <pshan...@yahoo.com> >Cc: Ben Tilly <bti...@gmail.com>; Jesse Luehrs <d...@tozt.net>; moose ><moose@perl.org> >Sent: Thursday, 12 January 2012, 18:06 >Subject: Re: "automatically" wrapping methods. > > >On Thu, Jan 12, 2012 at 9:39 AM, Peter Shangov <pshan...@yahoo.com> wrote: > >I am interested specifically in the event captured by >Sub::Mutate::when_sub_bodied(). I would like to be able to mess with a sub >immediately after it has been compiled, i.e. its prototype has been set, its >attributes have been executed, and its body has been defined, but before any >code has had an opportunity to invoke it. I imagine the >B::Hooks::EndOfScope::on_scope_end() approach would fail e.g. if there is a >BEGIN block calling the sub immediately after its definition. >Is there something in particular you're trying to do here? I'd imagine it's >Moose and validation related, as you're asking it in this thread, but without >more specifics... > > > > -Chris-- >Chris Weyl >Ex astris scientia > > >