in reply to Re: [OT: C] Getting pointers to functions
in thread [OT: C] Getting pointers to functions
I would suggest creating a C array of function pointers initialized to the addresses of the functions ...
Yes, I think that would have been a good starting point if I had stayed with my original intention.
However, in a subsequent discussion on the mpfr mailing list it was suggested that the best approach would be to rewrite mpfr_round_nearest_away() in perl, rather than wrapping it.
(This avoids the C99 requirement, avoids having to accommodate different C function prototypes and further allows the user to obtain "round to nearest, ties away from zero" for functions that the user might create.)
So I'm going with that approach. It's only a few lines of code and instead of using pointers to the mpfr library functions, it uses code references to the XS subs that wrap those mpfr library functions.
Calling it will be as simple as rndna(\&Rmpfr_foo, $rop, @args) where @args are the input args appropriate for the function Rmpfr_foo.
So there was a strong element of "XY problem" after all - largely due to the damned blinkers I habitually like to wear.
Cheers,
Rob