in reply to Re: Techniques On Saving Memory
in thread Techniques On Saving Memory

Is there some reason you didn't just write this as a wrapper over Devel::Pointer or Devel::Pointer::PP? They already handle the unsmashing part - you just add the part to get the hex address out of strings like "Some::Class=HASH(0x81471c8)". Or why didn't you just ask either Simon or me to update our modules? Its probably a feature that should already be in there.

Replies are listed 'Best First'.
Re^3: Techniques On Saving Memory
by japhy (Canon) on Mar 10, 2005 at 01:26 UTC
    I hadn't known of those modules until after I wrote mine. They were mentioned in other nodes in this thread. Now that I know they exist, there's no need for me to release mine; you and Simon just need to simplify your modules.
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      Actually, I like yours best. A few other things that would improve it (for my envisage purposes) are:

    • If it also returned the package name into which the reference was blessed, if it was blessed, in a list context.
    • If it had a deref() function that (optionally?) incremented the ref count.
    • If it provided a safe method of checking the unsmashed reference was still valid.
    • Had a function that would detect and return the type of the unsmashed reference--SCALAR/ARRAY/HASH etc, but also (if it is possible?), the the type of magic to which it is bound. Ie. Classname, or REGEX (I forgot how these get created?) etc.

      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.
        • I can see the "is it blessed" functionality being useful.
        • I'm not sure why you need to increment the ref count. Could you explain the reason?
        • I'll see how I can figure out whether there is a reference at the given memory location.
        • Determining the reference type and magic type shouldn't be too hard.
        _____________________________________________________
        Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
        How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart