On Fri, Sep 01, 2000 at 09:09:15AM -0700, Nathan Wiger wrote:
> First off, I think everyone is reading this RFC with the wrong mindset,
> my Dog $spot;
> print ref $spot; # 'Dog'
> $spot = new Dalmation;
>
> No reason this wouldn't still work. The term 'constructor' here is
> misleading. 'creator' is what I prefer, and that's also why I prefer
> CREATE.
It will work, but not the way you're expecting (I don't think).
Given:
package Dog;
sub CREATE { bless({ name => undef }, shift) }
sub name {
my $self = shift;
if (@_) {
return $self->{'name'} = shift;
}
return $self->{'name'};
}
I've annotated what the code does:
my Dog $spot; # $spot is now a blessed Dog object
$spot->name("Fido"); # $spot->{'name'} eq "Fido"
print ref $spot; # yes, "Dog"
$spot = new Dalmation; # now $spot is a Dalmation object
> At least, this is my take on it. CREATE would border right on the edge
> of internals, taking care of stuff that you normally wouldn't handle
> with new() anyways. Since it's a sub, you can put whatever you want into
> it, but CREATE != new() philosophically.
Unfortunately (because everyone seems to disagree with me) CREATE (or
PREPARE, or NEW, or author-defined) is new().
> And of course, Me != Michael, so I don't want to put too many words in
> his RFC. However, this is my take on it. I'm writing a massive RFC right
> now that tries to tie this all together. It's actually quite coherent,
> but when little bits and pieces are leaked admittedly it sounds
> disjointed.
Well, I guess I'll wait until that RFC comes out before asking you what
CREATE does, exactly, in your world. :)
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--