develooper Front page | perl.perl5.porters | Postings from June 2013

Re: Perl 5.18 and Regexp::Grammars

Thread Previous | Thread Next
Damian Conway
June 27, 2013 21:20
Re: Perl 5.18 and Regexp::Grammars
Message ID:
PS: I saw that Dave suggested:

> If the R::G's overload method were to return a qr// containing the
> string plus code, rather than returning a string, then things should
> Just Work (tm).


Except, as explained in my previous post, the overload method
can't just build and return a qr// each time its invoked, because:

    (a) it needs access to the entire contents of the original regex
        including the contents of interpolated variables (so it needs
        to use the return-an-object-that-accumulates-concatenations
        technique), and

    (b) even if it didn't need to accumulate interpolations, any code
        blocks in the original regex wouldn't then close over the
        correct variables, having been qr'd in the lexical scope of
        the overload sub, rather than the lexical scope of the
        original regex.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About