http://www.perlmonks.org?node_id=800824


in reply to Re: Perl is not Dynamically Parseable
in thread Perl is not Dynamically Parseable

I'm not sure what you mean here by "two instances of the Perl parser". I'm pretty sure I know what you're getting at, but I wouldn't call it two instances of the parser. It is more like two possible syntactic interpretations/parses of the same piece of code, depending on the prototype of a previously defined sub.

Saying "two instances of the parser" produce different things (on the same given code, presumably) makes it sound simply like the parser is non-deterministic or randomized.

blokhead

Replies are listed 'Best First'.
Re^3: Perl is not Dynamically Parseable
by ikegami (Patriarch) on Oct 13, 2009 at 00:54 UTC

    It is more like two possible syntactic interpretations/parses of the same piece of code,

    And what produces those two possible parses? Two parser instances. We're saying the same thing.

    Saying "two instances of the parser" produce different things (on the same given code, presumably) makes it sound simply like the parser is non-deterministic or randomized.

    Good.

      I don't know what the halting problem has to do with non-deterministic or randomized programs. The perl parser is deterministic, and it does not toss random coins. You can certainly insert randomness into a BEGIN block, but that's not what's going on here and it doesn't mean that parsing itself is randomized. Jeffrey's examples & undecidability proofs all involve deterministic BEGIN phases. If you run the parser a billion times on a deterministic program, you will get the same result every time. Different instances of the parser do not give different parses. The only way to get different parses is by having different behavior within the BEGIN block.

      blokhead

        Something I missed:

        Different instances of the parser do not give different parses.

        They do for some program. Did you (incorrectly) think I said it would happen for all programs? I said that once one finds a program where this happens, one can prove the non-parsability of Perl.

        The perl parser is deterministic,

        Parsing is the activity of assigning meaning to code. Since it's impossible to predict the meaning Perl will assign to code in some circumstances, the parser is non-determinisitc.