I did some studying on non-determinism.

An example of a non-deterministic algorithm is mergesort.

use sort '_mergesort'; my @sorted = sort { substr($a, 0, 1) cmp substr($b, 0, 1) } qw( foo bar baz );

It is guarantees that the results will the sorted, but the relative ordering of baz and bar is not specified. Therefore, mergesort is non-deterministic.


Let's see if we can replicate the same situation with the parser.

The goals of Perl's parser include the production of functions.

package Mod; BEGIN { my ($sub) = map "sub { $_ }", join ' ', map "$_();", sort { substr($a, 0, 1) cmp substr($b, 0, 1) } qw( foo bar baz ); } sub foo { print "$foo\n" }; sub bar { print "$bar\n" }; sub baz { print "$baz\n" }; 1;

The parser produces a function that calls foo(), bar() and baz(), but the order in which the calls are organized is not specified. Therefore, the parser is non-deterministic.


I don't know what that means wrt Perl's parsability, since I don't know I don't know how that's defined.


In reply to Re^4: Unparseability is A Good Thing by ikegami
in thread Unparseability is A Good Thing by Jeffrey Kegler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.