develooper Front page | perl.perl5.porters | Postings from January 2015

Re: RFC: "use re 'strict'"

Thread Previous
Karl Williamson
January 13, 2015 19:12
Re: RFC: "use re 'strict'"
Message ID:
On 09/05/2014 11:42 AM, Karl Williamson wrote:
> I'm proposing two additions to the "use re" pragma.  One is covered
> here, and the other in a separate thread, to lessen confusion.
> 'strict' would mean that any regex compiled within its scope would be
> subjected to stricter checking than otherwise.  For example, currently,
> $ perl -Dr -le 'qr/[z[:ascii]]/'
> Compiling REx "[z[:ascii]]"
> rarest char ] at 0
> Final program:
>     1: ANYOF[:[acisz] (12)
>    12: EXACT <]> (14)
>    14: END (0)
> What the programmer almost certainly intended, but neglected to include
> a crucial colon, was silently turned into something completely different.
> However, currently
> $ perl -Dr -le 'qr/(?[ [z[:ascii]])/'
> Compiling REx "(?[ [z[:ascii]])"
> Unmatched ':' in POSIX class in regex; marked by <-- HERE in m/(?[
> [z[:ascii <-- HERE ]])/ at -e line 1.
> When I was designing the (?[...]) extension, I did not feel so
> constrained by current practice, and put things like this in.  Some
> users have requested that all [...] behave like this, and this addition
> meets that request, via a selectable feature.
> I propose that we document this feature as being extensible so that we
> may, from time to time, add new strictures to those currently
> implemented without fear of breaking backwards compatibility.  That is,
> we may make things stricter in future releases to catch more errors that
> we don't do now, and if your code no longer compiles in that release,
> you'll have to change it rather than we back out the stricter
> strictures.  I'd rather not, but if that means marking this as an
> experiment, so be it.
> What the pragma would mean initially is yet to be fully determined.  It
> would mean at least all the things that (?[...]) prohibits or warngs
> about.  I would poll this list before adding things that I was not
> completely confident about.

I have now implemented this via commit 

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