in reply to Re: Unique numeric ID for reference?
in thread Unique numeric ID for reference?

I already looked at that, and it would work fine, but the problem is portability. If I use refaddr my code would only run on boxes with XS. I want the user to have the benefit of portability into situations where XS is not gonna happen.

thanks, jeffrey

Replies are listed 'Best First'.
Re^3: Unique numeric ID for reference?
by shmem (Chancellor) on Oct 06, 2007 at 22:39 UTC
    refaddr() is also provided by the non-XS version, and essentially does extract the numeric part of a stringified reference and returns its decimal value. It is slower than the XS version, though.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      I just looked at the code for Scalar::Util and the non-XS version of refaddr does a stringify, then a regex match to pull out the hex number. Simply putting an arbitrary unique ID into my records and dereferencing it isn't all that expensive, so I think that's going to have to be my answer.

      Since I'm doing pack, unpack hacks for the Guttman-Rosler-Schwartz transform, I was hoping for some pack/unpack wizardry. But if Graham Barr didn't use that kind of wizardry in Scalar::Util, that's very good evidence there is no such thing.

      thanks, jeffrey kegler

      I think you're right. Either refaddr is the answer to my question, or else there really isn't one.

      I'll check out the non-XS version for speed.

      Many thanks for your persistence in pointing me in the right direction,

      jeffrey kegler