Using SvPVX instead of SvPVbyte makes needless assumptions.

I'm sorry to have to start this all over again, but you are wrong. And here is why you are wrong.

The only thing that it makes sense to pass to a routine expecting a scalar containing a string of packed integers, is exactly that.

The only useful behaviour of those, is the trap. Because it tells me that I haven't passed a packed scalar. Immediately, and unambiguously.

If however, I call SvPVbyte, it won't prevent me from getting a trap if I pass an SV without a PV. But it will turn all the other cases into a piece of memory that there will be no way to discern was not a packed scalar of integers until I start getting garbage results.

And it could take me a long time to trace the source of that garbage back to the error.

The only assumption using SvPVX makes, is that I have passed a properly packed array. And if I haven't, it traps immediately, which tells me exactly where the problem lies.

In other words, the only assumption it makes, is that I know what I'm doing-- and immediately tells me, in no uncertain terms, if I do not.

And that's an invaluable behaviour in any piece of software!

I do not expect you to agree, nor want you to respond.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

In reply to Re^4: Need for (XS) speed by BrowserUk
in thread Need for (XS) speed by spx2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.