in reply to Re^4: Why reftype and blessed are making my life harder than it needs to be (XS/_reftype)
in thread Why reftype and blessed are making my life harder than it needs to be

Unfortunately, Data::Dump::Streamer is 5.6+ (though you don't have a "use 5.006;" line before your "use warnings;" line). This came up in the context of me helping JHUCKABY with DBM::Deep and I want to keep DBM::Deep able to run with older Perls.

It seems sad, though, that reftype() won't be patched to XSRETURN_NO, especially as that makes more sense. Also, why can't the Perl version be patched to at least return !!0 instead of explicit undef?


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re^5: Why reftype and blessed are making my life harder than it needs to be (XS/_reftype)

Replies are listed 'Best First'.
Re^6: Why reftype and blessed are making my life harder than it needs to be (XS/_reftype)
by demerphq (Chancellor) on Feb 10, 2006 at 14:22 UTC

    It seems sad, though, that reftype() won't be patched to XSRETURN_NO, especially as that makes more sense. Also, why can't the Perl version be patched to at least return !!0 instead of explicit undef?

    XSRETURN_NO is how you do return !!0 in XS.

    And the answer I think is here:

    D:\dev\>perl -e"print defined !!0" 1

    But Im hopeful that the p5p powers that be will be receptive of the idea of a _reftype() sub that returns PL_no instead of Pl_undef. (Which is what XSRETURN_NO and XSRETURN_UNDEF do.)

    ---
    $world=~s/war/peace/g

      That's a good thing, at least for reftype(). I can see wanting to return undef from blessed() because you can bless into the empty string. But, the empty string is the representation for one of the 8 Perl scalar types. Or, am I just completely confused?

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

        No, there is no perl intrinsic type that doesn't have a true value. And there are more than eight. We have: HASH, ARRAY, SCALAR, CODE, GLOB, IO, REF, and FORMAT, and then there is an intrinsic type that doesnt have its own designation, that being qr// objects, which report themselves as SCALAR but are actually not SCALAR refs. Oh, and i think in later perls you also have VERSION, (or something like that) but I could be mistaken.

        Regarding making reftype() return PL_no is that one must assume that people are doing

        if (defined(reftype($x))) { ... }

        or variants thereof. At least thats what I would expect the objection would be to changing the return of reftype. Hence my idea of providing a _reftype().

        ---
        $world=~s/war/peace/g