in reply to Re^6: A little overloading conundrum
in thread A little overloading conundrum

Thanks for the reply. (I haven't been able to access this webshite for the last 3 days.)
I was a bit confused by the fact that, with Choroba's script, the overloading was unaffected by the order in which package My::A and My::B were listed.
Eventually, I deduced that the overriding "use overload" directives were, courtesy of being inside an eval block, not executed until after both packages had loaded.
Anyway, I've been playing around with this approach and finding it to be relatively simple.

I've decided that the implementation should be effected by a standalone module (Math::GMP_OLOAD) which will handle the Math::GMP side of things regarding the handling of Math::GMP objects in Math::MPFR, Math::GMPq and Math::GMPz. So it will contain stuff like:
{ package Math::GMP; use overload "+" => sub ($$$) { my($x, $y) = (shift, shift); if(ref($y) eq 'Math::MPFR' || ref($y) eq 'Math::GMPq' || ref($y) + eq 'Math::GMPz') { return $y + $x; } return Math::GMP::op_add($x, $y, 0); }; use overload "-" => sub ($$$) { my($x, $y) = (shift, shift); if(ref($y) eq 'Math::MPFR' || ref($y) eq 'Math::GMPq' || ref($y) + eq 'Math::GMPz') { return -($y - $x); } return Math::GMP::op_sub($x, $y, shift); }; ....
Seems to be working ok.
I doubt that anyone else will make much use of it, but I might use it a bit - and it's an enjoyable little exercise, anyway.
It's nearly all done outside of the 3 modules it's supporting - ie it adds negligible clutter to those 3 modules.

Cheers,
Rob