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

Re: how should %^H work with lexical pramas

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
March 30, 2006 05:54
Subject:
Re: how should %^H work with lexical pramas
Message ID:
20060330135340.GE32132@plum.flirble.org
On Wed, Mar 29, 2006 at 05:33:27PM -0600, David Nicol wrote:
> I see two requirements being described in this thread:
> 
> 1:  a new data structure, the "masking hash", that has an attribute
> that says what
>      other (masking or non-masking) hash to look in when looking for a
> nonexistent key
> 
> 2:  an explicit scope identifier that is uniquely associated with a
> lexical scope
> 
> Both pieces would be useful in other contexts.
> 
> Writing masking-hash as a pure-perl tie or overload or magic would be
> simple enough,
> it would be better to do it explicitly rather than just for the pragmatic hints.
> 
> Given masking-hash, C<local> could be rewritten using maskinghash instead pf
> the current implementation and MJD's scalar localization tieing
> exploits would all
> fail.

I don't think that this would work, as it only affects where the lookup of
a particular name takes you. local needs to be able to localise specific
value containers directly, rather than just the name. For example, this works:

$ perl -lwe 'local $ARGV[1] = "Boo!"; print "@ARGV"' a b c
a Boo! c

Nicholas Clark

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