Hi Michael.
Thank you for your offer of the new functions. I appreciate your
willingness to contribute.
Date: Thu, 27 Nov 2014 14:45:24 -0500
From: "Andrew J. Schorr" <address@hidden>
To: Michael Plugge <address@hidden>
Cc: address@hidden
Subject: Re: [bug-gawk] missing function powm and friends
On Thu, Nov 27, 2014 at 03:49:37PM +0100, Michael Plugge wrote:
I wrote a small patch to use the powm() function (and also gcd() and
next_prime()) of gmp; this works even for very large parameters and
exponents. The appended patch file includes also an integer version of the
routines. It would be really great if it could be integrated into gawk :-).
I wish we could simply package this as a shared library extension, but the
problem is that the extension mechanism passes numeric values as double
precision numbers and does not expose the MPFR/GMP numbers used with -M. The
gawk-mpfr extension converts numbers to strings in order to pass them between
gawk and the library, so that is one approach to dealing with this.
I would recommend this as the way to make a first attempt at
packaging up these functions as an extension.
My sense is that there's a limited appetite for adding new functions to
gawk, and a preference for adding new functionality through extensions.
That is exactly right. I think these functions would be useful if
available as an extension. Michael, can you work with Andy to package
them into gawkextlib, either as part of the MPFR extension or as a small
standalone extension?
But it is challenging when considering extensions that would benefit
from the arbitrary-precision representation. Maybe it's worth giving
some thought to how to enhance the shared library interface to support
alternate numeric representations. That may be a big job.
This is worth some thought, but since it's not likely to happen very
soon, I suggest that you and Michael work to get his code into gawkextlib
now. It can be revised later once the gawk team figures out if and how
to pass MPFR values to/from an extension.