develooper Front page | perl.perl5.porters | Postings from March 2006

Re: how should %^H work with lexical pramas

Thread Previous | Thread Next
From:
hv
Date:
March 28, 2006 14:10
Subject:
Re: how should %^H work with lexical pramas
Message ID:
200603282218.k2SMId028578@zen.crypt.org
Nicholas Clark <nick@ccl4.org> wrote:
:Thanks to Robin's insight about passing %^H to eval, lexical pragmata work
:almost perfectly. As I understand it, the only thing missing is that code
:can't tell at runtime what the relevant compile time state of lexical pragmata
:was.
[...]
:So how should all this stuff work? I think there are actually two hashes, or
:things-with-a-hash-interface that need to exist. A read only thing that
:reflects the hints in force at the time of compilation of this statement.
:(This can be slow, but probably needs to be memory efficient). And a
:read/write thing which reflects/affects the compilation of the immediate
:lexical caller, if they are in compile time and we're in run time.
:
:Is this sane? If so, what are they called? And how best does the "read only"
:thing track any updates to the state of the read/write thing? And store them
:efficiently?

I'm not sure whether it's sane or not. Is the storage requirement restricted
to a) a copy of each unique set of values seen in %^H, plus b) a pointer
somewhere in the optree for each time it changes? If so, it would seem
sane enough as long as checking whether this is a new "unique set of values"
is fast.

Without the uniqueness check, there is a potential explosion of storage
requirement: if the hash ends up containing any real bulk, every tiny
change to it requires another copy of the bulk.

Or is there a third way? Some combination of (under the hood) local() and
'upvar', using a generation counter? That would probably qualify for
'slow but memory efficient'. And if we can avoid bothering to keep them
when they won't be needed that would be even cooler (but that's probably
a 'sawampersand' trap, better avoided).

Hugo

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About