in reply to Perl6 regex/pattern performance issues?

No, because optimization happens as a separate step. Once the compiler realizes that named captures aren't used, it won't capture them.

Phases aren't intertwined like perl5. Although this will slow down compilition, it will dramatically increase runtime speed, the ultimate goal.

  • Comment on Re: Perl6 regex/pattern performance issues?

Replies are listed 'Best First'.
Re: Perl6 regex/pattern performance issues?
by Abigail-II (Bishop) on Sep 04, 2002 at 11:17 UTC
    Once the compiler realizes that named captures aren't used, it won't capture them.
    But that means the compiler needs to be able to solve the halting problem. Which is, for Turing Machines, unsolvable. And since Turing Machines provide a more powerful machine than any physical computer does (due to their finite memory), not even the perl6 compiler will be able to solve this.

    Abigail

      Remember that it's only in the general case that you can't solve the halting problem. Many specific cases are easy to solve, and things can be designed to make it easier to solve those cases. In this particular case you'll note that, unlike Perl 5's dynamic scoping of the current successful match, Perl 6 makes $0 lexically scoped. That makes it pretty easy to tell how you've used $0 and its progeny within a particular block. Furthermore, the opaque $0 object is really not much more complicated than Perl 5's hidden match object. For most of the match, you've got to keep track of your state somewhere anyway. Perl 6 will undoubtedly do the same trick as Perl 5, and produce $1, $2, etc. lazily from the information.

      Named captures are really no different in that respect. The name is really representing an offset into a capture table, and no hash is ever really built, except to hold the symbol at compile time. Perl 6 also will likely escape the $& problem by using copy-on-write semantics generally.

        You mean, perl6 won't have eval?

        Abigail

Re: Re: Perl6 regex/pattern performance issues?
by John M. Dlugosz (Monsignor) on Sep 04, 2002 at 14:56 UTC
    If phases aren't intertwined, how can you create an input filter or new dialect of the parser? Is BEGIN going away?