|Think about Loose Coupling|
Re: Overloading multiplication involving BigIntby pileofrogs (Priest)
|on Jan 13, 2012 at 21:43 UTC||Need Help??|
No one else is commenting, so I'll take a wild stab.
Why not add more elsif branches to your sub? You say you're worried about bmul behaving badly if it's handed something other than a BigInt, so why not just check for it?
You could also run some tests or read the source to find out what bmul really does if the 2nd operand isn't a BigInt.
Why would you have to explicitly bless your integers if you made a subclass of Math::BigInt?
And to step back a little: are you sure you want to do overloading? Will future users (or yourself) be flummoxed that $a*$b isn't doing what they expect? Is typing '$obj->mult($other_thing)' really that bad? At least that way you know exactly what you just did.
Okay, that's about all I can think of. I hope I was helpful.