Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Considered having the return of MyLib::strToInt be the bool, and the param be the int? Usually subs/funcs return true false, and details of the operation are inplace updates/ pass by reference/ $_[0] = "hello";/*status = 1;/. Or the author of C++ method strToInt did it that way and thats the way you will remember it in Perl? You could also return 2 elements "($truefalse, $theint) = $instance->strToInt();", and have MyLib::strToInt method take only one param (THIS scalar). If the caller in perl doesn't want the int, they dont need to collect it in list context.

edit: With XS/C/Perl internals, the biggest XSUB debugging tool is looking at the .c code. Try posting that. For C code, you should learn how to create post C processor code, then run it through a code formatter. A 7 character named macro taking 1 param, barely or terribly documented, can expand to a screenful of code after 2-5 layers of macros are expanded. To understand why it failed, looking at the post preprocessor output it the only way. Also compile with optimize=debug and symbols, as you said already, you have a C debugger, so thats correct. Also instead of returning 1 bool, or a list, consider returning a hashref, a hashref is probably overkill for this function.

In reply to Re^2: xs modifying passed value by bulk88
in thread xs modifying passed value by Festus Hagen

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 00:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found