Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi,
I've read the overload documentation and I understand the basics of overloading the '=' operator. I also understand that it's not really an overloading of the '=' operator - rather there's a process, that begins with doing $copy = $orig, whereby $copy ultimately becomes a separate copy of the Math::GMP object $orig just prior to taking on a new value. In Math::GMP this can be demonstrated as: I have implemented the exact same thing in my Math::GMPz module - just replace all occurrences of "GMP" with "GMPz" and that little demo will behave in exactly the same way. But now to the bit that I don't understand: In Math::GMPz that overloading only works because, in GMPz.pm, I've done:
If I remove that key-value pair from GMPz.pm then that particular overloading ceases to work. In that demo, both $copy and $orig will then end up referring to the very same (original) object, but with the new value of 7 - and the script crashes on termination. OTOH, GMP.pm does not supply overload.pm with an '=', sub{} key-value pair at all. How come this overloading still works for Math::GMP ? Cheers, Rob In reply to How does Math::GMP overload the assignment operator ? by syphilis
|
|