|Pathologically Eclectic Rubbish Lister|
Unparseability is A Good Thingby Jeffrey Kegler (Friar)
|on Aug 23, 2009 at 01:26 UTC||Need Help??|
Apparently a previous posting of mine has been picked up by Perl-bashers. In retrospect, I shouldn't have been surprised. But I was.
The post I'm talking about proved the long-conjectured idea that Perl parsing reduces to the Halting Problem and is therefore not, in general, decidable. Stating that as "Perl is Unparseable" is a bit dramatic, but that was the terminology used in the discussion when I found it.
Unparseability is not a feature Perl folks need to be defensive about, or to minimize. Unparseability is one of the great things about Perl. OK, not unparseability in and of itself, but the ability to use the full power of the language at parse time. Because that full Turing machine power is what produces unparseability as a side effect.
Compile-phase processing is heavily used in Perl, and having the full language available at that point is one of its major advantages over other languages. That's why nobody ever talks about "fixing" Perl's unparseability. It's not a problem and doesn't need a fix.
With the usefulness of having the full language in the compile phase, contrast the unparseability downside: yes, there are potential Perl programs that cannot be parsed. None I've ever wanted to actually use, mind you. The only Perl programs I've encountered that don't parse are the artificial ones invented for the discussion of unparseability.
So the trade-off is practical power for theoretical purity. Thank you, Larry Wall. And, hey, designers of other languages! How come you didn't make such a smart trade-off?
So, monks, next time you hear Perl jeered at for having undecidable parsing, just tell 'em -- demanding a parseable language is the sign of weak programmer.
[ My proof is available in a series of three articles in The Perl Review, now available online. The TPR articles should be preferred to my original post because they are more fully explained, were carefully rewritten, and benefited from editing by brian d foy. ]