in reply to Re: Why do you need abstract classes in Perl?
in thread Why do you need abstract classes in Perl?
package AbstractFoo; ... sub new { my $package = shift; die "Don't subclass AbstractFoo directly!" if $package eq "AbstractFoo"; bless { @_ }, $package; }(Bonus points to whoever sees a way to generalize this even further.)
sub new { die "this is an abstract subclass" if $_[0] eq __PACKAGE__; shift->SUPER::new(@_); }
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Why do you need abstract classes in Perl?
by dws (Chancellor) on Mar 05, 2001 at 10:41 UTC | |
by merlyn (Sage) on Mar 05, 2001 at 12:01 UTC |