5 ms·
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
by andreyf 17y ago
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.
- deleted 17y ago[deleted]
- cabalamat 17y agoI 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.
- andreyf 17y agoMeh, "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.
- tolmasky 17y agoYes, but for a more practical example, this is defective in that it cannot be syntax highlighted correctly.
- barrkel 17y agoAnd syntax highlighting normally only requires lexical analysis, not syntactic analysis.
- mst 17y agoHacky 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 ...
- andrewljohnson 17y agoI 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.
- draegtun 17y ago... 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.
- cabalamat 17y ago> 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.
- mst 17y agoperl 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.