Hugo van der Sanden (via RT) writes: > Tels <perl_dummy@bloodgate.com> wrote: > :"khkramer@allafrica.com (via RT)" <perlbug@perl.org> wrote: > :>lead to $foo's reference count being high by one, if $foo is an object > :>that returns a reference to itself in its copy constructor. > : > :Uh, but isn't a copy constructor supposed to copy something, instead of > :merely returning the same thing? How should that supposed to work with a > :"defect" copy constructor? > : > :*puzzled* > > I couldn't see anything in the docs to state or imply that returning the > thing itself should be illegal, and I can see no reason for it to be so. > And if it should be illegal, we should make it an error rather than > silently doing the wrong thing. > In addition, if we "force" the copy constructor to actually copy something, a whole raft of common and useful approaches become tortuous and inefficient. I'm thinking particularly of while ( $foo++ ) {} # and if ( $foo++ ) {} constructions on iterator-like $foos. Thanks to Hugo for further stripping down the test-case to demonstrate that the problem isn't while- and if-centric (and mea culpa for not doing so myself), but my problems that led to submitting the bug report were exactly the above. If I have to actually copy my $foos in order to use the post-increment operator -- which include lots of stored state and (usually) a live database handle or two -- I'll have to stop using overloading. KwinThread Previous | Thread Next