Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Perl Cannot Be Parsed: A Formal Proof

by Anonymous Monk
on Jan 24, 2008 at 16:39 UTC ( #664070=note: print w/replies, xml ) Need Help??

in reply to Perl Cannot Be Parsed: A Formal Proof

Any language which has any sort of an eval construct “cannot be parsed” statically, because “that which is to be parsed” is determined at runtime. So it really doesn't take computer science to prove that.

Furthermore, let the record show that when you input any Perl program into the Perl compiler, it will be parsed, and you'll either get results or error-messages.

Bottom line is:   what's the point here? What are you saying about Perl, and about what (if anything) should be done to address this “issue?” What does this formality actually do for us as practitioners who make our daily bread from this tool?

  • Comment on Re: Perl Cannot Be Parsed: A Formal Proof

Replies are listed 'Best First'.
Re^2: Perl Cannot Be Parsed: A Formal Proof
by Anonymous Monk on Jan 28, 2008 at 01:48 UTC
    This is nonsense. Eval does not preclude parsing, unless results of evaluating something can alter the parse of another part.
      There are many languages that have "eval" and yet have unambiguous parse trees for the actual code of the program (as opposed to the code evaluated at runtime).

      If you run this Python program you'll see it prints out a complete parse tree of the program BEFORE it runs eval. Before you jump down my throat, I'm not saying that this makes Python a better language than Perl. It's just a fact that a language can be constructed so that "eval" is totally handled at runtime and does not affect the parsability of the program.

      import sys import parser print parser.suite(open(__file__).read()).totuple() x = eval(sys.stdin.readline()) if x: print "yes", x else: print "no", x
      To bring this back to the original post, the "parser" module is the Python equivalent of what Parse::Perl would be if Perl parsing were possible.
      He is saying that in order to statically parse an eval block, you must know when_it_halts - or in otherwords - what it does; this is impossible with out actually running the eval block, and is clearly related to the halting problem.

        If he's saying that, then he's wrong. The problem is not the existence of eval; the problem in Perl 5 is barewords and prototypes.

Re^2: Perl Cannot Be Parsed: A Formal Proof
by Anonymous Monk on Jan 25, 2008 at 21:47 UTC
    Acme is the 'joke' department for cpan modules, a place to prank and have fun. I wouldn't use it as part of a paper.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://664070]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2021-05-09 02:44 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (100 votes). Check out past polls.