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

Re: how should %^H work with lexical pramas

Thread Previous
March 28, 2006 18:00
Re: how should %^H work with lexical pramas
Message ID:
Nicholas Clark <> wrote:
:On Tue, Mar 28, 2006 at 11:18:39PM +0100, wrote:
:> Nicholas Clark <> 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.
:> [...]
:Possibly jumping ahead to implementation - run time reading of the frozen
:state of %^H is likely to be rare, so I was wondering if holding a single
:linked list of HE structures without actually having a hash.
:In turn, it should be possible to hold a back reference up to the outer
:enclosing lexical scope, so each scope needs only hold a vector of the
:changes. Deletions could be stored by having a value of PL_sv_placeholder.
:But I'm not sure if I'm jumping the gun here, and also I'm not sure how much
:work it is to get to the point of being able to generate that sort of
:structure. With it in place, reading it via magic on %^H is relatively

It sounds good, and it sounds necessary - or at least necessary enough
until we decide the overhead outweighs the benefit.

My main worry is the new warts it introduces: mainly that if you store a
value in this hash it'll keep its refcount to global destruction, even
if you're just doing a:
  @a = do {
    use sort qw/ stable /;
    sort @a
.. and as soon as someone invents a reason to put objects in there (or a
bug gets one in there by mistake) that can get nasty.

(My other worry was storage, but normal use would only require a small
percentage of optree size, and I don't think anyone's yet designed a use
for hints that gets pathological.)

Perl6 is intended to give far better introspection capabilities, is there
anything we can steal from the approach there? Having an interface would
at least be a guide for implementation.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About