On Fri, Sep 01, 2000 at 08:59:10PM -0000, Perl6 RFC Librarian wrote:
> Furthermore, it proposes that both C<SETUP> and C<DESTROY> methods
> should be invoked hierarchically in all base classes.
This bothers me. It leaves no way to override the behavior of a
parent's SETUP and DESTROY, you can only overlay. You mentioned that
this is normal for most other OO languages, so I presume there's a way
to deal with this?
Also, having never really desired hierarchical DESTROYs, its not
obvious to me why this is useful. Could you explain why? (and for the
benefit of those who don't own OO Perl or made the mistake of loaning
it out.)
PS Proposing SETUP, UNIVERSAL::new() and the hierarchical calls are
three unrelated issues and should probably be three different RFCs.
> =head2 Proposed standard C<UNIVERSAL::new>
>
> Given that most Perl classes are hash-based and that the C<SETUP> method
> cleanly separate construction and initialization, it might be desirable to
> have the UNIVERSAL class always supply a default constructor:
>
> package UNIVERSAL;
>
> sub new { bless {}, @_ }
Shouldn't that be:
sub new {
my($proto) = shift;
my($class) = ref $proto || $proto;
bless {}, $class;
}
I prefer new() to be both an object and a class method and don't see
any harm in it. (Boy I hope I didn't just touch off a holy war).
Also, do we want to do anything with the rest of the arguments? Perhaps...
sub new {
my($proto) = shift;
my($class) = ref $proto || $proto;
bless {@_}, $class;
}
So UNIVERSAL::new() will take a hash as its argument to initialize the
object.
--
Michael G Schwern http://www.pobox.com/~schwern/ [EMAIL PROTECTED]
Just Another Stupid Consultant Perl6 Kwalitee Ashuranse
Like you've never accidentally spanked a midget.
-- Siobain http://www.goats.com/archive/index.html?000106