in reply to Re^4: ExtUtils::ParseXS has changed
in thread ExtUtils::ParseXS has changed

Since PDL_Long * pos is the RETVAL

I don't think so...

Reading http://perldoc.perl.org/perlxs.html#The-NO_INIT-Keyword again, I see I have misread

After checking the generated Basic/Core/Core.c, I'm guessing it is an regression

Also, it seems to me that any initializations using NO_INIT need to go after CODE

Replies are listed 'Best First'.
Re^6: ExtUtils::ParseXS has changed
by syphilis (Archbishop) on Aug 17, 2011 at 10:09 UTC
    Reading http://perldoc.perl.org/perlxs.html#The-NO_INIT-Keyword again, I see I have misread

    When I read that link it seems to me that the current PDL code is totally misusing the NO_INIT keyword.
    Looks to me that the variable 'pos' is simply a variable that has a value assigned to it - which, one suspects, is (by itself) insufficient to make it an "output" variable at all.

    Also, it seems to me that any initializations using NO_INIT need to go after CODE

    No, it needs to go *before* CODE. (Perhaps that's what you meant.) With both 2.2210 and 3.03, when I put PDL_Long * pos = NO_INIT; in the CODE section I get an error such as:
    Core.xs:673: error: `NO_INIT' undeclared (first use in this function)
    Cheers,
    Rob

    Update: This has now reached the point where I'm thinking I should probably present the function in its entirety. So here it is as it currently appears in Core.xs (which is autogenerated from Core.xs.PL):
    SV * at_c(x,position) pdl* x PDL_Long * pos = NO_INIT CODE: int npos, ipos; double result; pdl_make_physvaffine( x ); pos = pdl_packdims( ST(1), &npos); if (pos == NULL || npos < x->ndims) croak("Invalid position"); /* allow additional trailing indices * which must be all zero, i.e. a * [3,1,5] piddle is treated as an [3,1,5,1,1,1,....] * infinite dim piddle */ for (ipos=x->ndims; ipos<npos; ipos++) if (pos[ipos] != 0) croak("Invalid position"); result=pdl_at(PDL_REPRP(x), x->datatype, pos, x->dims, (PDL_VAFFOK(x) ? x->vafftrans->incs : x->dimincs), PDL_REPROFF +S(x), x->ndims); SET_RETVAL_NV(x) ; OUTPUT: RETVAL
    To reiterate - that will work fine as is with 2.2210, but only works with 3.03 if there is a typemap entry for 'PDL_Long *'. (With 3.03 it doesn't seem to matter what that typemap entry specifies - as long as there is one.)
    If I don't amend the typemap, then to make that Core.xs work with both 2.2210 and 3.03 I have to remove the PDL_Long * pos = NO_INIT and begin the CODE section with a PDL_Long * pos; declaration.

      When I read that link it seems to me that the current PDL code is totally misusing the NO_INIT keyword.

      Yes, this.

      No, it needs to go *before* CODE. (Perhaps that's what you meant.)

      No, I meant after CODE, without NO_INIT , like you did in your tests, PDL_Long * pos;