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

Re: [perl #116639] regex optimiser wrongly rejects certain matchesinvolving embedded comments

Thread Previous | Thread Next
From:
demerphq
Date:
October 19, 2015 09:34
Subject:
Re: [perl #116639] regex optimiser wrongly rejects certain matchesinvolving embedded comments
Message ID:
CANgJU+XU42HYD0qV4TY8Gcxhx=r+sJWCffzcidFJ=4HGEjb=ww@mail.gmail.com
On 19 October 2015 at 04:50, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
> * Karl Williamson <public@khwilliamson.com> [2015-10-18T00:16:44]
>> Just to make sure everyone understands.
>>
>> Currently (?#...) comments are allowed even when there is no /x.  We
>> probably have to support that in the places where it's been that way all
>> along, but we could decide to not support them in the places that I just
>> added, when not under /x.  Thus, we could say that you can't split a
>> quantifier from its atom except under /x.
>
> Thanks, I was confused.
>
>> I don't have an opinion on this.
>
> I'm not strongly opinionated on this, but:  I think that I would find it useful
> to say:
>
>   If you want to put comments into a regular expression, you have two
>   options.  You use /x and then insert space and any kind of comments between
>   tokens, or you can skip /x and use (?#...) between tokens.
>
> That is: always allow (?#...) in those places where space and comments become
> allowed under /x.


I really dont like this. A) it complicates the regex engine, and B) it
makes a mockery of what an expert would consider to be one token.

so for instance to *me*: a{1,10} is a single token.

a(?#whatever){1,10}

is two "tokens".

I think expecting people to grok that

/a


























{1,10}/x

is the same as /a{1,10}/x

is IMO just asking for trouble and for people to misunderstand what is going on.

Related, would you expect

\(?#is this a \w match or not)w

to be the same as

\w

?

Its not, but IMO if you think that a(?#foo){1,10} should be the same
as a{1,10} then why shouldnt \(?#whatever)w?

Of course, it wouldnt work, as \( would mean that (?#whatever) is not
treated as a comment at all.

So this idea just increases inconsistency in our regexes for IMO
basically no value.

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