in reply to Mmmm ... cargo cult progamming is nummy!
in thread Adding autoloaded methods to symbol table with using strict refs
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; trick used to add "make me a new one of these" semantics to the standard "make me a new instance of this package" semantics.
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Re: Mmmm ... cargo cult progamming is nummy!
by merlyn (Sage) on Feb 27, 2002 at 00:47 UTC | |
by dws (Chancellor) on Feb 27, 2002 at 04:23 UTC | |
by merlyn (Sage) on May 19, 2003 at 08:30 UTC | |
by dws (Chancellor) on May 19, 2003 at 17:51 UTC |
In Section
Seekers of Perl Wisdom