in reply to Re: Math::BigInt::GMP - direct access to the gmp integer value
in thread Math::BigInt::GMP - direct access to the gmp integer value

Without the mg_virtual test your code would return NULL, and probably crash somewhere

I haven't yet managed to get that to happen. Perhaps I'm just not trying hard enough.
(Note to self: investigate what happens if NULL gets returned.)

Update: Just tested what happens if NULL gets returned, and it's fine - just falls through to the slower overloading via stringification.
The fun will start when a non-NULL (but incorrect) pointer gets returned.

Current state of this code is to be found in the Math::GMPz module on github:
git clone git@github.com:sisyphus/math-gmpz Math-GMPz
The code in question is the C code (in GMPz.xs) that pertains to the overloading of operations with Math::BigInt objects - which is most of the overload_* subs in GMPz.xs.

Cheers,
Rob