develooper Front page | perl.perl5.porters | Postings from April 2010

Also, what should 'local @tied[4,6,8]' do?

Thread Next
From:
David Nicol
Date:
April 13, 2010 10:15
Subject:
Also, what should 'local @tied[4,6,8]' do?
Message ID:
i2q934f64a21004131008vbb652d2cn638a3f92b9920185@mail.gmail.com
On Sun, Apr 11, 2010 at 2:17 PM, Dave Mitchell <davem@iabyn.com> wrote:


> Anyway, I can see three possibilities for the behaviour of 'local @tied':
>


A fourth, or maybe zeroth, possibility would be for localizing a tied array
to throw an exception.

What happens with localizing slices of tied hashes? Or slices of arrays?

    local @ENV{qw/PATH USER/} = qw(/umkc/lib/garden hlinda);

Making the operation on @arr equivalent to the operation on @arr[0..$#arr]
makes sense, but that might be broken too ( i do not know )

calling STORE and FETCH on a tied array (or a tied hash slice) a lot seems
wrong, as the side effects could be horrible.

maybe local(@tied) could be disallowed under strict?

maybe local could introduce a wrapper layer that would intercept accesses to
the localized elements and refer them to in-memory data?

   local @ta;

would use the non-tied option, and

   local $ta[4]

would become something like

   $saved = \@ta;
   tie @{*ta = []}, Tie::Array::Overlay => $saved, 4

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