laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
> I'd overload = to automatically clone the object on assignment.
Sorry, that's too easy to misunderstand. Let me be more precise: $b = $a with = overloaded to ->clone will not do an immediate $b = $a->clone ° It's rather a kind of copy-on-write. After the assignment the refs will still be identical : $b == $a The ->clone ("copy" in COW) will only happen delayed just prior to changing $b or $a ("write" in COW)
But the wording is fuzzy and needs to be tested. Anyway this could indeed fix the problem of the OP in an efficient way.
Cheers Rolf °) In Math::BigInt the cloning is done with the method ->copy In reply to Re^3: Action at a distance
by LanX
|
|