develooper Front page | perl.perl5.porters | Postings from July 2009

Re: delete local $a[$idx] - delete local $h{$key}

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
July 27, 2009 05:49
Subject:
Re: delete local $a[$idx] - delete local $h{$key}
Message ID:
b77c1dce0907270549p1c5a5decsfe82805259d3e8ca@mail.gmail.com
2009/7/25 Vincent Pit <perl@profvince.com>:
> I've just pushed a "deletelocal" branch to the repository that contains
> the implementation of "delete local $a[$idx] - delete local $h{$key}".
> This syntax was actually valid for a long time (at least since 5.6) but
> didn't do anything. Following a suggestion from Ricardo, I've made it
> equivalent "delete $a[$idx]; local $a[$idx]", except that it returns the
> value before the localization.

That's not really the equivalent, since $a[$idx] is restored afterwards, right?

> There are no changes to the grammar. The optree changes are minimal (now
> OP_DELETE also accepts OPpLVAL_INTRO). It works for (?:arrays|hashes)
> (?:references)? (?:subscripts|slices).
>
> You can find it at :
>
>    http://perl5.git.perl.org/perl.git/shortlog/refs/heads/deletelocal
>
> Tests, reviews and comments welcome.

This is a nice new feature and the implementation looks neat.

Not sure where to document this -- probably with the local() main docs.

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