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

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

Thread Previous
From:
Rafael Garcia-Suarez
Date:
February 21, 2003 09:03
Subject:
Re: [perl #21321] local ${"FOO"} does not work
Message ID:
20030221180408.49bddfad.rgarciasuarez@free.fr
Mark Jason Dominus <mjd@plover.com> wrote:
> Rafael Garcia-Suarez <rgarciasuarez@free.fr>:
> > Mark Jason Dominus <mjd@plover.com> wrote:
> > > 
> > > Perhaps the best way to address this would be to extend the peephole
> > > optimizer to optimize ${"COMPILE_TIME_CONSTANT"} to
> > > $COMPILE_TIME_CONSTANT.
> > 
> > While not breaking strict 'refs.' As says perlref :
> > 
> >     use strict 'refs';
> >     ${ bareword };      # Okay, means $bareword.
> >     ${ "bareword" };    # Error, symbolic reference.
> 
> I'm not quite sure what your point is here, but I would say that if
> strict 'refs' complains about ${"word"} when "word" is a compile-time
> constant, it is defective, and my suggestion will make it less so.  

This point can be discussed with good arguments on both sides.

However, this enhancement to the optimizer will not allow things like
	no strict 'refs';
	local ${ some_expr_that_evaluates_to_a_string() };
which in my opinion are harmless, unlike "local $$x" where $x
is actually a reference. (although I need some experiments to convince
myself of that)

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About