in reply to Re: Capturing parenthesis and grouping square brackets
in thread Capturing parenthesis and grouping square brackets
TL;DR Perl 6 accords Perl 5 special status, with many elements specifically designed to make P5/P6 interop straightforward. And, for those who want it, transition.
There is no evolutionary transition-plan here; not does one appear to be possible, let alone economical, let alone particularly beneficial.
Imo the ways in which P6 design and implementation bridges with P5 demonstrate great care about interop and evolutionary transition at both a big picture and tiny detail level.
First, sticking to just regex:
- The P5 regex modifier allows Perl 5 regex syntax to be used. This marries Perl 5 regex syntax and semantics to the power and elegance of Perl 6 match objects. Hence the ability to visually debug Perl 5 regex using the Rakudo Perl 6 debugger.
- Some P6 features exist partly/mostly to make things easier for a P5 programmer. For example, the ability to reset the numbering of regex captures will help P5 coders used to consecutive subpattern numbering in alternations and unnested numbering in nested subpatterns.
- Compiler messages help P5 programmers pick up P6. For example, the Perl 6 parser defines an infix =~ operator, which fails at compile time with a message helping P5 coders.
It's not just regex either:
- Mixing P6 and "pure" P5. Last year Larry Wall wrote a Perl 6 grammar (parser) for a substantial subset of Perl 5. Enough that it parsed (but did not compile) viv, a utility written in Perl 5 (4K LOC). This year FROGGS turned that grammar into a v5 module for rakudo, a pure Perl 5 compiler. (He is working his way through a P5 testsuite based on the #p5p perl testsuite.)
- Mixing P6 and Perl 5 with XS. blizkost embedded libperl in Parrot, so Rakudo could eval Perl 5 code using #p5p perl. It didn't do much and Rakudo needed to focus on other things. Fast forward to today. Libperl is due to be embedded in MoarVM, a new VM for NQP/Rakudo. The architecture is such that Rakudo Perl 6 will be able to use #p5p perl, including XS, and vice-versa.
Please visit the IRC channel #perl6 on freenode and help improve it by constructively discussing things you think will improve transition or interop between P5 and P6. Thanks go to Larry, jnthn, and all who try to help. Illegitimi non carborundum! :)