in reply to Java Style Interface Objects?

If you want to validate your object, just check!

sub new { #... bless $self, $class; for my $check (qw(func1 func2 rarelyused)) { die "$class doesn't have method '$check'" unless $self->can($check +); } }

Of course, even then, if $class actually has an AUTOLOAD function, can doesn't play nice with that, and you end up thinking it can't do something when it can, just fine, through the AUTOLOAD method.

Replies are listed 'Best First'.
Re^2: Java Style Interface Objects?
by chromatic (Archbishop) on Feb 04, 2006 at 04:00 UTC
    Of course, even then, if $class actually has an AUTOLOAD function, can doesn't play nice with that...

    Sure it does. Predeclare your subs or write your own can() method.