in reply to Re^4: Pronoun Programming
in thread Pronoun Programming

There are several ordered hash implementations on cpan already that use tie and arrays to achieve their goal: Tie::Hash::Sorted, Tie::Hash::Array, Tie::Hash::Rank, Tie::Hash::Index, Tie::SortHash, Tie::LLHash etc.

I'm intrigued by your assertion that HE* have a link back to the hash. Nothing shows up on the PerlGuts Illustrated diagram?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^6: Pronoun Programming
by plobsing (Friar) on Feb 07, 2008 at 01:56 UTC
    I was mistaken. Should have paid a little more attention while reviewing extending and embedding perl. $hash in the following structure refers to the hashed value of the key, not the hashtable from which the HE came. Confusing terminology.
    # from Extending and Embedding Perl, section 4.5 $HE = { NEXT => $HE_next, HEK => { HASH => $hash, LEN => length($key), KEY => $key, } VAL => $SV, };
    My approach didn't try ordering, so the hash was actually based on a hashref, not an array.

    I looked over the tie modules on CPAN (the first 20 pages before I got bored). None of them seemed to implement the functionality of what I envisioned as a solution: A tied hash that gives defered processing objects as results.

    Being interested in something in inverse proportion to how useful that thing is, I expanded upon my ideas in the previous post. I think it caught feauture-use-itis though (2 tie classes and an overloaded inside-out class is a bit much complication for one module, IMHO).

    I called it Tie::LazyHash, but it probably would be better named Tie::DeferredLookupRefHash. But that's just ugly sounding.

    You can do a couple of things with the lookup values that invoke the actual lookup (which can be invoked multiple times for the same object):
    $elem->delete; $elem->exists; $$elem = $x; print $elem; # overloaded for convenience print $$elem;