Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Method Calls on multiple objects

by diotalevi (Canon)
on Mar 27, 2004 at 06:17 UTC ( [id://340221]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://340221]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-25 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found