develooper Front page | perl.perl5.porters | Postings from February 2011

Re: [perl #84774] local $_ calls STORE when $_ is aliased to a tiedhash element

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
February 24, 2011 05:47
Subject:
Re: [perl #84774] local $_ calls STORE when $_ is aliased to a tiedhash element
Message ID:
AANLkTimJseS5XTL5Yy6oEz1uh7dDcEiX3a=fRidE4nuN@mail.gmail.com
On Thu, Feb 24, 2011 at 6:16 AM, Jan Dubois <jand@activestate.com> wrote:
> On Wed, 23 Feb 2011, Leon Timmermans wrote:
> But how would you trigger the call to LOCALIZE?
>
> I don't want
>
>    local $_;
>
> to call LOCALIZE on the existing value of $_.  I expect it
> to put the existing value on the savestack and leave $_ with
> a new SV, and I expect the old value to be automatically
> restored when execution leaves the current scope.
>
> So how would LOCALIZE come into play?  Would that be triggered
> by a new builtin, e.g.

I mean that local would do the equivalent of

  tied($foo)->LOCALIZE($new_variable) if tied($foo) &&
tied($foo)->can('LOCALIZE');

That way we could fix this bug yet and also allow us to unbreak
File::chdir by adding such a LOCALIZE method. There's a svt_local slot
in the magic vtable specially for this kind of scenario. it shouldn't
be too hard to implement. Or am I overseeing something in this jungle
of magic and indirection?

Leon

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