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

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

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
February 27, 2011 11:27
Subject:
Re: [perl #84774] local $_ calls STORE when $_ is aliased to atied hash element
Message ID:
20110227192742.GA9560@klangraum.plasmasturm.org
* Jan Dubois <jand@activestate.com> [2011-02-25 06:25]:
> An alternative would be to only treat "local $_" specially.
> This could be done at compile time, so wouldn't need any SV
> flags at runtime.

I vote for this. `$_` represents an unnamed scalar, it refers to
the implicit topic of a section of code, whereas all other
variables are explicit names of particular values.

The `local $PWD = '/some/where'` interface of File::pushd makes
intuitive sense: `$PWD` is inherently special and I am locally
assigning this special kind of a variable a new value. You can
imagine the same thing for a variety of other kinds of variables,
eg. if I saw `local $UMASK = '0007'` is just as natural.*Only*
for `local $_` does this intuitive expectation differ because
`$_` is not the name for one particular special thing.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

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