rootcho has asked for the wisdom of the Perl Monks concerning the following question:

hi, In a MyClass I use something like this :
use Class::Delegation ...... send => -OTHER, to => -SELF->page; sub page { ${$_[0]}{app}{currTran}{currPage} }
This means that any method (except several i didnt mentioned here for simplicity) should be redirected to $self->page->method().
Then I have in my code script.pl :
use Aspect; before { ..... } call qr/^MyClass/;
when I run it I get :
... MyClass::Application::AUTOLOAD-> Could not delegate at /...../lib/Aspect/Hook/LexWrap.pm line 63 MyClass::Application::DESTROY->
I see that Delegation probably didn't succeeds because page() is dynamic and for some reason conflicts with Aspect.
If I try to isolate AUTOLOAD from Apsect i.e.
before {....} call qr/^MyClass/ & !call qr/AUTOLOAD/;
I get another error :
Can't call method "match_define" without a package or object reference + at /...../lib/Aspect/Pointcut/NotOp.pm line 13.
Can you figure out some workaround for this situation ? Should I stop using Class::Delegation and do everything with AUTOLOAD instead ?
I really wanted to use delegation 'cause it would simplify the things alot. On the other hand I want to use Aspect to pin-from-outside Logging, debuging and other functionality.. Now i'm still testing..

Continued : it seems that even if I don't use Class::Delegation, Aspect still has problems ;(
It does something with AUTOLOAD, because if I don't use Aspect, $AUTOLOAD variable is populated and everything goes fine, but at the moment I enable Aspect, $AUTOLAOD is empty!!

More: I continued experimenting with Aspect and similar..here you can see examples :
http://perlmonks.org/?node_id=592845
I sent email to the author of Aspect, probably he can figure out, why..
Does someone have idea how can I cleanly slice the subs/methods i.e. install code inside them, even if I have to put some hook-code.
Of cource doing this in Aspect consistent way. thanx

Replies are listed 'Best First'.
Re: Aspect and Class::Delegation
by aufflick (Deacon) on Jan 02, 2007 at 23:20 UTC
Re: Aspect and Class::Delegation
by diotalevi (Canon) on Jan 03, 2007 at 16:51 UTC

    Class::Delegation has to solve the problem of catching only some errors and rethrowing others. It isn't perfect that way. If you aren't comfortable fixing Class::Delegation so it rethrows your real exceptions properly then you shouldn't use it. You should submit a simplest case RT bug for this.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊