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

Re: what should 'local @tied' do?

Thread Previous | Thread Next
From:
Vincent Pit
Date:
April 11, 2010 12:42
Subject:
Re: what should 'local @tied' do?
Message ID:
4BC22724.5020804@profvince.com

> There are a couple of long-standing open tickets (from Michael Schwern)
> to the effect that with tied arrays and hashes,
>     local @tied
> doesn't DWIM (RT #7938, #7939).
>
> The current behaviour of local @tied is to create a new array, store it
> in the ARRAY slot of *tied, and then I<attach tie magic to the new array
> too>. This makes the local essentially a noop, and gives the following
> behaviour:
>   

> My preferences in descending order are 2,1,3.
>   

Just a couple of notes to add to the discussion :
- localized tied scalars remains tied.
- when I implemented "delete local $a[$i]/@a[@list]" and optimized "@a =
reverse @a" in the case of a tied array, I made it to check the
existence of elements by calling the EXISTS method, and then delete the
element as needed by calling DELETE. I considered that if you were using
tied variables, you were already accepting an important perfomance hit
and so I decided to aim for the most correct answer (in the context of
tied variables) despite the cost of calling EXISTS and DELETE.


Vincent.


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