Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can only 'perl6' parse Perl 6?

There's that (relatively) well known Perl axiom, "Only perl can parse Perl." I'm wondering, will that remain true for Perl 6?

Expanding the discussion... I thought of this question given the recent update of PyPy. Does Perl's unique parsability preclude it from similar efforts? Is there much value in a restricted, static view of Perl code (PPI?)? Can Perl 6 have a JIT compiler?*

* I'm not sure if these concepts are related. Are they?

like image 616
Mark Canlas Avatar asked May 06 '11 19:05

Mark Canlas


2 Answers

There is no perl6, and there are many Perl 6 compilers. Perl 6 has a grammar, although it's written in Perl 6, so as long as you can understand that, it tells you everything you need to know.

I just asked Larry this question, since I'm sitting across from him at lunch at the São Paulo Perl Workshop. He says it's now "Only Perl 6 can parse Perl 6", with capital letters on both Perls, which means something different than the original statement.

You don't need a specific program to do that though since Perl 6's goal is one standard and many implementations. There is no "perl6", although Larry had that aliased to his Rakudo for today's talk, even though he used a few different implementations for the examples.

like image 121
brian d foy Avatar answered Sep 22 '22 02:09

brian d foy


Last I looked, Perl 6 inherits Perl 5's / character, which can mean "beginning of regex" when a term is expected, or "divide" when an operator is expected. Given that, and prototypes, and Perl 6 is at least in the same camp as Perl 5 for static tokenization. The only way to tokenize a Perl 6 program is to have a running Perl 6 interpreter in the Perl 6 compiler. Turtles all the way down, once again.

like image 28
Randal Schwartz Avatar answered Sep 22 '22 02:09

Randal Schwartz