in reply to Re: Re: Why do you need abstract classes in Perl?
in thread Why do you need abstract classes in Perl?
The use of __PACKAGE__ was what I was looking for. I was thinking along the lines of
package AbstractFoo; ... sub new { my $package = shift; die __PACKAGE __ . " is an abstract class" if $package eq __PACKAGE__; bless { @_ }, $package; }
merlyn and I had a back and forth in the CB about the difference between his solution and mine. I noted that his would fail if nobody in AbstractFoo's superclass chain implemented new. merlyn agreed, saying (and here I'll ask him to correct me if I get the details wrong) that this was correct behavior, given that there's no generic way to implement new. I granted that point, but cited the Smalltalk image as evidence that there were common patterns. That, in essense, is where we left the discussion.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Why do you need abstract classes in Perl?
by merlyn (Sage) on Mar 05, 2001 at 12:01 UTC |