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

Perl's magic is like black magic to me :)

Not only do I not know how it works, but I also don't even know what it does !!

Those are two different objects and have different addresses

Thank you for wading through the code and spotting that - much appreciated !!
I'll need to chew this over for a while.

It means I either have to do something that will ensure that the addresses match, or just remove the problematic condition from the code.
The latter is appealing, as I know immediately how to do that (and it reduces overhead). But I'm initially loathe to take that action as I don't know what risks it might create.

Anyway - that's something I can work on.
Thanks again.

Cheers,
Rob
  • Comment on Re^2: Math::BigInt::GMP - direct access to the gmp integer value

Replies are listed 'Best First'.
Re^3: Math::BigInt::GMP - direct access to the gmp integer value
by Anonymous Monk on Jan 10, 2016 at 05:53 UTC
    Not only do I not know how it works, but I also don't even know what it does !!
    My reading of that code is that it uses magic mostly to store the pointer to mpz in mg->mg_ptr. perlguts says its okay: "Extensions can use "PERL_MAGIC_ext" magic to 'attach' private information to variables (typically objects). This is especially useful because there is no way for normal perl code to corrupt this private information (unlike using extra elements of a hash object)". Then there is also that copying function dup_gmp_mpz, apparently for use with ithreads.
    But I'm initially loathe to take that action as I don't know what risks it might create.
    As far as I can tell, the risk is that something else will attach magic (with tag PERL_MAGIC_ext) to your Math::BigInt::GMP variable, and then you'll get wrong mg->mg_ptr. How likely is that? Probably pretty unlikely...