Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXPERIMENT] variable-length look-behind #18756

Open
rjbs opened this issue Apr 30, 2021 · 18 comments
Open

[EXPERIMENT] variable-length look-behind #18756

rjbs opened this issue Apr 30, 2021 · 18 comments
Labels
experiment ticket tracking an active experiment

Comments

@rjbs
Copy link
Member

rjbs commented Apr 30, 2021

Limited variable-length look-behind was first released in perl v5.30.0 as an experimental feature. This issue tracks its progress toward the end of its experimental phase.

@rjbs rjbs added the experiment ticket tracking an active experiment label Apr 30, 2021
@rjbs
Copy link
Member Author

rjbs commented Jun 20, 2021

I have proposed on p5p that we mark this a success.

@jkeenan
Copy link
Contributor

jkeenan commented Jun 21, 2021

I have proposed on p5p that we mark this a success.

Do we have any criteria for determining whether an experiment has been successful or not (other than "people haven't complained about it")?

@hvds
Copy link
Contributor

hvds commented Oct 3, 2021

The main issue in my mind is whether the semantics are sane.

If I understand it correctly, when we determine the lookbehind expression has width in the range {m, n}, we attempt to match the whole expression on the anchored substring s[-n:-1]; if that fails, we try again on s[-n+1:-1] and repeat up to s[-m:-1]. That effectively means we prefer the longest match, unlike the rest of the regexp engine.

Thus for example a?? will ignore the requested minimality and ($FOO|$BAR) will prefer the longer rather than the first of the alternates.

This won't usually affect whether something matches, but it can affect captures, and could defeat attempts to optimize a pattern using the normal rules. Not sure what other issues it could cause.

% perl -E 'no warnings qw{experimental}; "abfoo" =~ /(?=foo)(?<=(a??b))/ and say $1'
ab
% perl -E 'no warnings qw{experimental}; "abfoo" =~ /(?=foo)(?<=(b|ab))/ and say $1'
ab
%

(I had a typo in the above first time I tried it, which led to #19168.)

I don't have a solution to offer, it may be that these semantics are ideal, or that they are more nearly ideal than any other. However I don't recall to what extent this was discussed when VLB was first implemented, and it's worth considering before we bless them as final.

@hvds
Copy link
Contributor

hvds commented Feb 21, 2022

@demerphq has now looked at #19168, which showed that VLB currently has a major bug; that led to PR #19442. I think the PR has a good chance of making it for the upcoming release (needs more tests, and more eyes), but this case further convinces me that VLB as a whole is not ready to be marked a success.

I still hope someone will one day comment on the issues mentioned in my previous comment here.

@demerphq
Copy link
Collaborator

demerphq commented Feb 21, 2022 via email

@rjbs
Copy link
Member Author

rjbs commented Feb 21, 2022

Thanks, you two. I have been pursuing this exiting experimental only because it seemed to be not moving and to work. I am not in a rush, and will back off until post-5.36!

@demerphq
Copy link
Collaborator

demerphq commented Feb 21, 2022 via email

@khwilliamson
Copy link
Contributor

khwilliamson commented Feb 22, 2022 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@khwilliamson
Copy link
Contributor

khwilliamson commented Feb 23, 2022 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@hvds
Copy link
Contributor

hvds commented Feb 23, 2022

My initial concern here was that it didn't feel like there had been much discussion of the semantics. @demerphq has convinced me at least that the current semantics are coherent enough to be viable (though I'm not as completely convinced that they are necessary or ideal).

My newer concern is that a pretty huge issue such as #19168 was not found by people using it in the wild, which suggests to me it has had minimal take-up even for the //i context that motivated @khwilliamson to add it - I'm not sure on what basis we can declare the experiment successful if nobody has used it.

@jkeenan asked at the top of this issue:

Do we have any criteria for determining whether an experiment has been successful or not (other than "people haven't complained about it")?

.. which I don't think ever got an answer.

@demerphq
Copy link
Collaborator

demerphq commented Feb 23, 2022 via email

@khwilliamson
Copy link
Contributor

khwilliamson commented Feb 23, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment ticket tracking an active experiment
Projects
None yet
Development

No branches or pull requests

5 participants