in reply to Re^7: 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

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

  • Comment on Re^8: Why reftype and blessed are making my life harder than it needs to be (XS/_reftype)
  • Download Code

Replies are listed 'Best First'.
Re^9: Why reftype and blessed are making my life harder than it needs to be (XS/_reftype) (breaking compat)
by tye (Sage) on Feb 10, 2006 at 15:04 UTC

    Don't make a new name, change the behavior at 'use' time. For example, if a module version number of at least X is demanded, then backward compatability behavior would not be required (so the function with saner behavior would be exported).

    - tye        

      Thats a great idea. Im just wondering how you would implement that? A custom import? Or something else?

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

        See use, look for "VERSION". You need only define your own "sub VERSION", though this unfortunately might not be thread-safe (or as easy as it could be if 'import' and 'VERSION' weren't separated). Though I guess you could just use a hash keyed off the path of the including file...

        - tye        

Re^9: Why reftype and blessed are making my life harder than it needs to be (XS/_reftype)
by dragonchild (Archbishop) on Feb 10, 2006 at 14:38 UTC
    Gah. Because it was done wrong, all future versions have to do it wrong because people have a hack around it being done wrong. That's sad.

    Suggestion: Don't call it _reftype(). Call it what_reftype_shoulda_done()


    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?