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

Re: how should %^H work with lexical pramas

Thread Previous
From:
hv
Date:
March 28, 2006 18:00
Subject:
Re: how should %^H work with lexical pramas
Message ID:
200603290208.k2T28bY28825@zen.crypt.org
Nicholas Clark <nick@ccl4.org> wrote:
:On Tue, Mar 28, 2006 at 11:18:39PM +0100, hv@crypt.org wrote:
:> 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.
:> [...]
: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
:trivial.

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.

Hugo

Thread Previous


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