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

Re: Perl 5.18 and Regexp::Grammars

Thread Previous | Thread Next
From:
Damian Conway
Date:
June 27, 2013 21:20
Subject:
Re: Perl 5.18 and Regexp::Grammars
Message ID:
CAATtAp4FCbmRCXeYBHFFjxQkhDPMvvHTDhDTKJ05YzukHqoFAw@mail.gmail.com
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).

Indeed.

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.

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About