Thanks for the input.
There's some thoughts there that probably gel with a lot of people. They also gel with me to some extent.
The attraction for me of taking/returning SVs in the C function is that I don't always know precisely what is being taken/returned.
For example, with the overload routines, I know that the first arg will always be a Math::GMPz object (and I'll probably now get around to changing that first arg from
SV* to
mpz_t* in those routines), but the 2nd arg can be any one of an IV, NV, PV, or a number of different objects (Math::GMPz, Math::GMPq, Math::MPFR, etc.).
It's convenient to just call it an SV and then let the overload routine work out exactly what it is, and how to deal with it.
Similarly, not all of those overload routines always return a Math::GMPz object - sometimes some of them may return a Math::GMPq or Math::MPFR object.
Again, it's nice to just specify the return as an
SV* and let the typemapping sort out exactly what it is.
Now, admittedly, I could do away with the C functions altogether, and have everything done inside the XS subs, but that's just putting the spaghetti into the meatballs.
There's nothing wrong with that, but I'm quite happy to have the spagehetti and the meatballs kept adjacent to each other. Changing that aspect of the current procedure strikes me as being more trouble than it's worth.
But having said that, I do see an opportunity to remove a lot of simple C functions - which I intend to do.
Having had a very quick look at https://github.com/sisyphus/math-gmpz/blob/master/typemap, is there a reason all those identical "types" aren't just the one?
I don't think their identical. I believe that all occurrences of "$type" and "$var" represent separate, unique values.
It's probably only mpz_t, mpq_t and gmp_randstate_t that need to be specified.
I guess the other ones are there just in case they're ever needed.
Thanks again,
etj.
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.