Re:Why Python Is Slow: Looking Under the Hood
by haberman on Tuesday November 18, 2014 @04:26PM
(#8626459)
> Basically, you can't always parse a Perl program without running it.
That is true, but what the grandparent said is not: https://news.ycombinator.com/item?id=8626454
To expand on this, I think a succinct way of summarizing the issue is: you might have to run BEGIN blocks in Perl to parse the non-BEGIN-block part of the program. The canonical example of this is:
BEGIN {
if(arbitrary_function()) {
eval "sub whatever() { }; 1" or die $@;
} else {
eval "sub whatever { }; 1" or die $@;
}
}
# The parsing of this line depends on the result of arbitrary_function()
whatever / 25 ; # / ; die "this dies!";
arbitrary_function() can be anything, so the only way to parse the rest of the program is to actually run arbitrary_function().
Basically, you can't always parse a Perl program without running it. There is a subset that you can, not not everything.