Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Math::GMP

Native Rust implementation built into the interpreter. Runtime: P5. See original documentation for the full Perl reference.

Functions

import

mirrors lib/Math/GMP.pm:73-79.

Called as: Math::GMP->import(‘:constant’)

When ‘:constant’ is in the import list, registers native_new_str as the overload::constant handler for integer literals. This is the compile-time hook that makes 2 ** 100 use GMP arithmetic.

perl5 Math/GMP.pm:78: overload::constant integer => sub { Math::GMP->new(shift) }

In pperl we call the same interp-level machinery that overload_constant (mod.rs) uses: set HINT_NEW_INTEGER | HINT_LOCALIZE_HH in interp.hints and store a CV pointing to native_new_str in GvHV(interp.hintgv)[“integer”].

new_str

Creates a Math::GMP object from the string form of the literal.

perl5 GMP.pm:78: sub { Math::GMP->new(shift) } shift = $_[0] = the string form of the literal token (decimal integer string).