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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.