What an XS module does when it wants to process a list of bytes is of course up to the XS module's author
Ok - but I guess the module author (me) should probably document the procedure that the module takes. (The lack of any such documentation seems to have been a part of ribasushi's objection, and I think that's fair enough.)
For simplicity, let's stick to a single-byte string:
use Math::GMPz qw(:mpz);
my $z = Math::GMPz->new();
my $v = 255;
$str = chr(ord $v);
Rmpz_import($z, 1, 1, 1, 0, 0, $str);
print $z; # prints the value assigned to $v (ie 255).
But let's say the user instead does a utf8::upgrade of the string, as per the following:
use Math::GMPz qw(:mpz);
my $z = Math::GMPz->new();
my $v = 255;
$str = chr($v);
utf8::upgrade($str);
Rmpz_import($z, 1, 1, 1, 0, 0, $str);
print $z; # now prints 195.
The crux of the issue is "what do I (the module author) conclude regarding the expectation of the user that wrote that second block of code ? "
As I see it, I have only 3 choices:
a) conclude that the user's expected result is to see an output of "255";
b) conclude that the user's expected result is to see an output of "195";
c) conclude that I have insufficient information to know what output the user expects (except that the user will be expecting either "255" or "195").
Which is the correct conclusion for me to reach ?
I can accommodate either 'a)', 'b)', or 'c)' and I think the answer is probably 'c)', but I'd just like an
informed opinion on that.
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.