|
|
| "be consistent" | |
| PerlMonks |
Re: Mmmm ... cargo cult progamming is nummy!by dws (Chancellor) |
| on Feb 27, 2002 at 00:25 UTC ( #147776=note: print w/ replies, xml ) | Need Help?? |
|
What that's really doing is co-opting your constructor (typically called new()) and using it as a copy function, (typically called copy() or clone()).
I have rarely seen the equivalent of a copy constructor in someone's new method. Rather, I've seen the
my $class = ref $proto || $proto; If you're restricted to created instances of a named class, you have extra hoops to jump through to extend your software to accomodate new subclasses. By adding a "make me new one of these" capability, you defer past compile-time the decision of what package to create a new copy of.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||