News for hackers. Stuff that matters.
Re:Perl Cannot Be Parsed: A Formal Proof by andreyf on Thursday August 13, 2009 @01:56PM (#761306)
Keep in mind that the term "parse" here is being used in its strict sense to mean static parsing -- taking a piece of code and determining its structure without executing it. In that strict sense the Perl program does not parse Perl. The Perl program executes Perl code, but does not determine its structure.

A less alarmist title would have been "Perl cannot be parsed unambiguously without runtime information". A less technical summary:

    whatever  / 25 ; # / ; die "this dies!";
Could be parsed both as (using parentheses to show arguments):

    whatever( / 25 ; # / ); 
    die "this dies!";
Or:

    whatever / 25; # the rest is a comment
This depends on whether `whatever' is a function of one argument or not, which you don't know until runtime.
Re:Perl Cannot Be Parsed: A Formal Proof by cabalamat on Thursday August 13, 2009 @02:18PM (#761371)
I once attempted to learn Perl, several years ago. I always felt I was walking on quicksand because I was never sure how a program should be parsed. It's nice to confirm that it wasn't just my unfamiliarity with the system; the actual design of the lanugage is deeply, deeply defective.
Re:Perl Cannot Be Parsed: A Formal Proof by draegtun on Thursday August 13, 2009 @03:29PM (#761508)

   ... lanugage is deeply, deeply defective
With great power comes great responsibility ;-)

If i switch on warnings it will provide... well warnings on this example! If I run Perl::Critic over it then it spews lots of things that I should be concerned about!

You're unfortunately over sensationalising what is otherwise a very good Perlmonks article.

Re:Perl Cannot Be Parsed: A Formal Proof by cabalamat on Monday August 31, 2009 @06:26AM (#795688)
> With great power comes great responsibility

Most people agree that Lisp is very powerful. Yet Lisp isn't hard to parse, in fact its syntax is extremely simple.

Re:Perl Cannot Be Parsed: A Formal Proof by mst on Thursday August 13, 2009 @04:17PM (#761606)
perl tries to be more human friendly; the trick is to write the code in the way that seems to best express your intent to a human reading it, and assume that the compiler will do the right thing.

Later you'll be able to work out the rules that it uses to resolve things and take advantage of them, but perl is designed for people who -don't- want to be thinking about what the compiler's doing while writing code.

Alternatively, you can simply -not use- the syntax sugar and thereby avoid needing to worry about it for your own code.

Re:Perl Cannot Be Parsed: A Formal Proof by andreyf on Thursday August 13, 2009 @02:21PM (#761376)
Meh, "defective" is a strong word. It really depends on what you want out of your language - if you want static code analysis or a macro system, then yes, it's defective. If you're looking to write a language that people use to write scripts here and there, then it's just a question of taste.
Re:Perl Cannot Be Parsed: A Formal Proof by tolmasky on Thursday August 13, 2009 @02:38PM (#761414)
Yes, but for a more practical example, this is defective in that it cannot be syntax highlighted correctly.
Re:Perl Cannot Be Parsed: A Formal Proof by mst on Thursday August 13, 2009 @04:19PM (#761616)
Hacky perl can't be highlighted

Sensibly written perl highlights just fine - and you really need to commit intentional pathology to break the modern vim/emacs/etc. highlighters.

Personally I find syntax highlighters less helpful and more annoying than the wavy green line grammar check in word, but as a consultant I get to use editors with highlighting often enough and don't remember the last time I broke one ...

Re:Perl Cannot Be Parsed: A Formal Proof by barrkel on Thursday August 13, 2009 @02:48PM (#761440)
And syntax highlighting normally only requires lexical analysis, not syntactic analysis.
Re:Perl Cannot Be Parsed: A Formal Proof by alxv on Thursday August 13, 2009 @03:33PM (#761520)
Conversely, automatic indentation requires syntactic analysis.
Re:Perl Cannot Be Parsed: A Formal Proof by barrkel on Saturday August 15, 2009 @07:32PM (#765363)
However, most pretty printers only perform lexical analysis.
Re:Perl Cannot Be Parsed: A Formal Proof by andrewljohnson on Thursday August 13, 2009 @02:57PM (#761461)
I learned Perl in a single week to do a dirty job that needed doing in the 90s. I'd use Python for the task today.