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

Re: [perl #21321] local ${"FOO"} does not work

Thread Previous | Thread Next
From:
Enache Adrian
Date:
February 21, 2003 09:11
Subject:
Re: [perl #21321] local ${"FOO"} does not work
Message ID:
20030221171110.GA907@ratsnest.hole
On Fri, Feb 21, 2003 at 08:25:56AM +0200, Jarkko Hietaniemi wrote:
> > > > Bleadperl or 5.8.0:
> > > > 
> > > > $ ./perl -e 'local ${"FOO"}=1'
> > > > Can't localize through a reference at -e line 1.
> > > > $ 
> > > > 
> > > > What reference where?
> 
> > > Ronald J Kimball <rjk@linguist.Thayer.dartmouth.edu>:
> > > That's a symbolic reference, isn't it?
> 
> Syntactically yes, but semantically it isn't, all that needs to be
> known about the variable name is known in compiletime.  In other
> words, I would have expected the above to be equivalent to ${FOO}
> or $FOO.
> 
> > Mark-Jason Dominus:
> > Perhaps the best way to address this would be to extend the peephole
> > optimizer to optimize ${"COMPILE_TIME_CONSTANT"} to
> > $COMPILE_TIME_CONSTANT.
> 
> Yup, something like that.

This cannot go without making lexical variables accessible through
symbolic references.

I don't think it would be acceptable that '$a="b"; $$a' and '${"b"}'
work differently ( since ${"b"} would be optimized to $b, it will
access the lexical in the first place, unlike $$a ).

IMO, it's preferable to keep the old behavior.

Regards

Adi

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