Thanks Joost. Sorry, I should have said that I was returning an array ref from the XSUB, but then post-processing that in Perl. Like so:
$results = $self->_Run( @_ ); # This is the XSUB return @$results if( wantarray ); return undef if( scalar( @$results ) == 0 ); return $$results[ 0 ] if( scalar( @$results ) == 1 ); return $results;
That's the current implementation, but it needs to change as people don't seem to like the fact that it's context aware. They'd rather its return type was constant.
Option 1 is to recode it like this:
$results = $self->_Run( @_ ); # This is the XSUB return @$results;
and simply have the perl wrapper always return an array. The other option is to use XPUSH to return a list instead.

I'm trying to figure out what my users will gain from that implementation over the one above. Can you see anything?

In reply to Re^2: Return array or list from an XSUB? by smee30
in thread Return array or list from an XSUB? by smee30

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.