develooper Front page | perl.perl5.porters | Postings from May 2016

Re: [perl #128213] No deprecation warning on literal left curlybracket in /.{/ etc

Thread Previous | Thread Next
From:
demerphq
Date:
May 24, 2016 22:55
Subject:
Re: [perl #128213] No deprecation warning on literal left curlybracket in /.{/ etc
Message ID:
CANgJU+VAaBYNA9KmKwg2ZuN5YprOp=AJ9fFmDohMz+hWvO9Acg@mail.gmail.com
On 24 May 2016 at 21:30, Zefram <zefram@fysh.org> wrote:
> Tom Wyant via RT wrote:
>>Karl's addition of "... and not after an assertion" makes sense to
>>me on the face of it, since it makes no sense (to me) to quantify an
>>assertion. If ^ matches once at a given location, it will match any
>>number of times.
>
> That would make some sense if such a rule were being added, but it's not.
> /\A/ is such an assertion, and everything you say about /^/ applies
> equally to /\A/.  Yet /\A{/ has been deprecated at the same time as /x{/.
> There is no exception to the deprecation for assertions.
>
> If assertions were a consistent exception, I'd still be opposed to that.
> They're not an exception to quantifier syntax: /\A{3}/ is a quantified
> assertion, as is /^{3}/.

While I generally agree with what you said in this post this point is
not quite right.

$ perl -wle'qr/\A{10}/'

Quantifier unexpected on zero-length expression in regex m/\A{10}/ at -e line 1.

We DO consider a quantifier on an assertion to be warnable, and IMO we
should probably do something like reduce any quantifier on an
assertion to something like ? (IOW, 0 or 1).

So

/\A{10}/

should be the same as

/\A/

and

/\A{0,10}/

should be the same as

/\A?/

Obviously we would want to propagate quantifier modifiers through as well.

cheers,
Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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