in reply to Re: Method Calls on multiple objects
in thread Method Calls on multiple objects

->can isn't effective for checking methods handled by AUTOLOAD.
  • Comment on Re: Re: Method Calls on multiple objects

Replies are listed 'Best First'.
Re: Re: Re: Method Calls on multiple objects
by chromatic (Archbishop) on Mar 27, 2004 at 20:04 UTC

    It certainly is, if you program correctly. Either predeclare or override can().

      We've discussed this before, but not properly. Ie unfortunately don't have time to give it justice now, either.

      Suffice it to say for now that I continue to disagree with you on what correct programming is. Furthermore I'd suggest avoiding setting up expectations that the majority will do things right (for virtually any values of right).

Re: Re: Re: Method Calls on multiple objects
by dragonchild (Archbishop) on Mar 28, 2004 at 00:25 UTC
    sub generate_method { my $self = shift; my ($name) = @_; my $method = <generate method and put into namespace>; return $method; } sub can { my $self = shift; my ($name) = @_; if ( <some rule that determines when a method is handled by AUTOLO +AD> ) { return $self->generate_method($name); } $self->SUPER::can($name); } sub AUTOLOAD { my $name = our $AUTOLOAD; $name =~ s/.*::([^:]+)$/$1/; my $self = shift; if ( <some rule that determines when a method is handled by AUTOLO +AD> ) { return $self->generate_method( $name )->(@_); } $self->SUPER::AUTOLOAD( @_ ); }

    Now it is ... kinda. It's slower and annoying, but can be done.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose