in reply to Re^3: Why doesn't perl optimize this?
in thread Why doesn't perl optimize this?

You seem to believe in magical powers of static code analysis in a dynamic language.

plz tell me

sub func { my ($code,@a) = @_; my $b = [@a]; eval $code; return $b; }

How is the compiler supposed to know that '@a' can be destroyed w/o knowing what happens in '$code' at runtime?

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^5: Why doesn't perl optimize this?
by nbtrap (Sexton) on Jun 05, 2013 at 01:57 UTC
    I agree that the compiler can't know in the case you cite. But what about the case I cited?
      > But what about the case I cited?

      It's extremely complicated and risky to cover ALL edge cases. It's not worth it and BrowserUK already told you!

      If you think such code analysis is easy, please better try implementing a JIT compiler for Perl...

      Cheers Rolf

      ( addicted to the Perl Programming Language)