bmdhacks has asked for the wisdom of the Perl Monks concerning the following question:
My question is, in my new() method, I would like to return undef on failure. What is the correct method for doing this? Does something like this work:TYPEMAP cstruct * T_OBJECT
Is the cast above the correct way? Or should I have my constructor return an SV* and then coerce my pointer into an IV? Thanks for the help.cstruct * new( field ) int field; CODE: if( something_wrong() ) { /*** is this correct below??? ***/ RETVAL = (cstruct *)&PL_sv__undef; } OUTPUT: RETVAL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: perlxs new() returning undef
by tye (Sage) on Mar 14, 2001 at 01:09 UTC |