in reply to Re^6: How does Math::GMP overload the assignment operator ? (more guessing)
in thread How does Math::GMP overload the assignment operator ?

Is there a string conversion overload in Math::GMPz? Perl has quite a few ways to construct overloaded operators from other operators, and one possibility is to first convert the object to a string and then use the builtin string->number conversion.

  • Comment on Re^7: How does Math::GMP overload the assignment operator ? (more guessing)
  • Download Code

Replies are listed 'Best First'.
Re^8: How does Math::GMP overload the assignment operator ? (more guessing)
by syphilis (Archbishop) on Nov 11, 2020 at 01:30 UTC
    one possibility is to first convert the object to a string and then use the builtin string->number conversion

    Yes, that seems consistent with the behaviour I've noticed.
    In the absence of a specified '0+' overload subroutine, $array[Math::GMPz->new(-2)] would be stringified to $array["-2"] and then numified to $array[-2]

    Cheers,
    Rob