in reply to Re: Inheritance and calling a subclass method *from* a baseclass method...
in thread Inheritance and calling a subclass method *from* a baseclass method...
I would use Carp::confess in this case. And I probably wouldn't check if the method was overloaded on new(). Please consider the following example:
package MyPackage; use strict; use warnings; use Carp qw(confess); sub new { my ($class) = @_; my $self = {}; bless $self, $class; return $self; } sub abstract_method { my ($self) = @_; my ($method) = ( caller(0) )[3]; confess "${method} should be overloaded."; } package main; my $p = MyPackage->new(); $p->abstract_method();
Don't you think it is cleaner?
Igor 'izut' Sutton
your code, your rules.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Inheritance and calling a subclass method *from* a baseclass method... (error data)
by tye (Sage) on Mar 04, 2007 at 03:42 UTC | |
by izut (Chaplain) on Mar 04, 2007 at 12:36 UTC | |
by tye (Sage) on Mar 04, 2007 at 13:35 UTC | |
by izut (Chaplain) on Mar 04, 2007 at 21:27 UTC | |
by tye (Sage) on Mar 04, 2007 at 21:49 UTC |
In Section
Seekers of Perl Wisdom