tlhackque has asked for the wisdom of the Perl Monks concerning the following question:
From perl, we can sayfoo * routine(a, b, c=NULL) char *a; int b; bar_t * c; CODE: RETVAL = croutine( a, b, (c && SvOK(ST(2)) ) ? c : cdefault ); OUTPUT: RETVAL
ormy $c = $objref; routine( $a, $b, $c);
BUT, if we say:routine( $a, $b);
We fail with "c is not a reference" at runtime, when the interface code sees that c is not a reference.my $c; $c = $objref if( false ); routine( $a, $b, $c );
This is because $c contains undef. But I'm prepared to supply another value in this case. (Note the SvOK(ST(2))).
How do I tell XS that a reference OR undef is OK for a parameter (c)?
Many thanks,
This communication may not represent my employer's views, if any, on the matters discussed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XS: How to enable passing ref or undef?
by syphilis (Archbishop) on Oct 16, 2010 at 01:05 UTC | |
by tlhackque (Beadle) on Oct 16, 2010 at 10:22 UTC | |
by juster (Friar) on Oct 18, 2010 at 23:15 UTC | |
|
Re: XS: How to enable passing ref or undef?
by andal (Hermit) on Oct 18, 2010 at 11:09 UTC |