in reply to AUTOLOAD - the good, the bad, and the ugly
A snippet from IOC::Lite follows:
sub AUTOLOAD{ my($self, @args) = @_; my @method_and_structure = split m|\:\:|, $AUTOLOAD; my $method = $method_and_structure[@method_and_structure-1]; if ($self->{object}->can($method)){ return $self->{object}->$method(@args); } die ">$method is not found on " . $self->get_type() . "\n"; }
I've taken the concept a little further, almost AOP like, in the version of IOC::Lite I'm working on now. That way I can add all types of features to objects the container doesn't own. The basic component management methods will be first, followed closely by dynamic logging. Not sure where I'll head from there.
Sorry if this is just rambling. Bottom line: I think it would be quite useful on large software projects. I can't tell you how many times I wished I had this feature when coding in (C/C++/Java/etc)
John
janitored by ybiC: Replace frowned-upon <pre> tags with Monastery-standard <code> tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: AUTOLOAD - the good, the bad, and the ugly
by dragonchild (Archbishop) on Oct 15, 2004 at 04:23 UTC | |
by ihb (Deacon) on May 05, 2005 at 00:29 UTC |