develooper Front page | perl.perl5.porters | Postings from October 2004

RE: optimization idea

Thread Previous | Thread Next
From:
Orton, Yves
Date:
October 26, 2004 02:30
Subject:
RE: optimization idea
Message ID:
E471ED2DFD9353458E8B75FD6D6B0307B637D5@defra1ex4.de.mcilink.com
Dave Mitchell wrote at 25 October 2004 22:38:
> On Mon, Oct 25, 2004 at 09:09:16PM +0200, Elizabeth Mattijsen wrote:
> > Wouldn't you need to add taking a ref of the var, to 
> invalidate this 
> > optimization?  Specifically for this case:
> > 
> > sub statename {
> >     my $name = 'david';
> >     ${\$name} = 'liz';
> >     return "hello, my name is $name";
> > }

But surely in this case the ${\$name} should itself be optimised to $name
first? So it becomes 

sub statename {
    my $name = 'david';
    $name = 'liz';
    return "hello, my name is $name";
}

And then would become

sub statename {
    return "hello, my name is liz";
}

> 
> Then there's stuff like this, which you can't detect at compile ime:
> 
>     sub statename {
> 	my $name = 'david';
> 	eval '$name = "liz"';
> 	return "hello, my name is $name";
>     }

You cant detect the consequence of the eval but you can detect the eval no?
So you could disable the optimisation if there is no eval between the
constant assignment and the stringification....

BTW, all of this im speaking entirely hypothetically and only out of
curiousity as to whether im correct here.

Cheers,
yves

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