Hacker News new | ask | show | jobs
by saba2008 1582 days ago
Somewhat related:

Perl Cannot Be Parsed: A Formal Proof (2008) https://news.ycombinator.com/item?id=5770531

1 comments

Well, to be a little pedantic, Perl cannot be statically parsed, since some constructs require runtime context.

If it could not be parsed it could never work!

And this is totally OK in my book, I use Perl for prototyping ideas and an expressive language that allows creativity from me the programmer is a feature as it promotes looking at a problem from multiple aspects.

> Well, to be a little pedantic, Perl cannot be statically parsed, since some constructs require runtime context.

If you're going to be pedantic, it's important to be correct; there's no such thing as dynamic parsing.

> If it could not be parsed it could never work!

What's the logic here? An interpreter doesn't have to operate on an AST, a language doesn't have to have a nontrivial grammar (consider Brainfuck). Perl is just a language in the same category: it doesn't have a (true) nontrivial AST, it doesn't have a (true) nontrivial grammar, and it can't be (truly, nontrivially) parsed.

> there's no such thing as dynamic parsing

As long as we're indulging in pedantry, this is incorrect presuming dynamic means what it usually means. Any regular expression constructed at runtime contradicts you.

Modifying your core parser at runtime though, who would do such a thing? Other than reader macros in Common Lisp I mean. Are we going to argue this means Common Lisp doesn't parse if we add reader macros at runtime? A peculiar argument.

Now. Should we talk about whether doing that is a good idea? A lovely and separate conversation. I agree with GP that since Perl will spit out a parse tree, it does in fact parse, and since it's not static, well, it's dynamic.

Which we can prove by, I dunno, writing some Perl which only parses on Fridays. Right?

> Modifying your core parser at runtime though, who would do such a thing?

Perl? Its numerous language extensions allowed it to stay competitive for such a long time. Every time someone says "language X can do Y but Perl doesn't have that syntax", a new CPAN module is born to amend the shortcoming.

> Are we going to argue this means Common Lisp doesn't parse if we add reader macros at runtime? A peculiar argument.

Peculiar how? Isn't that just common sense?

“Cannot be X” most often means “in the general case”. (In the context of computability.)