in reply to Re: Return array or list from an XSUB?
in thread Return array or list from an XSUB?
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.$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;
and simply have the perl wrapper always return an array. The other option is to use XPUSH to return a list instead.$results = $self->_Run( @_ ); # This is the XSUB return @$results;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Return array or list from an XSUB?
by Joost (Canon) on Nov 14, 2007 at 12:45 UTC | |
by smee30 (Initiate) on Nov 14, 2007 at 12:57 UTC |