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

[perl #128213] No deprecation warning on literal left curly bracketin /.{/ etc

Thread Previous | Thread Next
Tom Wyant via RT
May 24, 2016 19:06
[perl #128213] No deprecation warning on literal left curly bracketin /.{/ etc
Message ID:
On Mon May 23 16:09:05 2016, wrote:
> Karl Williamson wrote:
> >And, I want to make the rule simple to follow.
> In that case, *every* unescaped brace should be subject to the
> deprecation.  /^*/ and /^{3}/ both parse as a quantifier on /^/, so /^{/
> should be deprecated as looking like an incomplete quantifier, just like
> /.{/.  /*/ and /{3}/ error as "quantifier follows nothing", so /{/ should
> be deprecated as looking like an incomplete quantifier following nothing.
> -zefram

Boy, when I turned back the corner of this carpet I had no idea how many creepy-crawlies would come swarming out. And I appreciate very much Karl's fulsome explanation of what is going on, and support the reasons for doing the work.

The problem with applying Occam's razor is that which is the simpler alternative can depend on how you look at them.

I personally am happy with something like "un-escaped literal '{' is deprecated/removed where and only where it can introduce a quantifier." That statement means to me to mean "not at the beginning of a group (or the regex as a whole)" for sure.

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. Given that, I personally, for whatever little that is worth, would look on the current parse of /^{3}/ as a bug (or at least a misfeature), and would be happy to see that sort of thing deprecated and eliminated. But that's just me, and far more Perl-savvy people than me have been wrong about such apparently-obvious things. The thing is, this could be looked at as the thin edge of the wedge, since it means a deprecation warning for '/^ {/' but not '/^ {/x'.

The funny thing is, all this was started by my desire to release a PPIx::Regexp that shows literal '{' removed in 5.25.1 (at least, in those cases where it is in fact removed), and realizing that I did not understand either the documentation or what Perl was actually doing. My motivation may be important in evaluating my opinions, because they will almost surely be influenced by the ease or difficulty of the implementation I face. "Always removed" is certainly trivial, but "removed except at the beginning of a group and after an assertion" is not much harder.

The tricky thing may be to implement what looks like the actual removal, with some things disappearing now, and some not disappearing until 5.29.x. So if someone could let me know exactly what deprecations are being deferred, I would greatly appreciate it. Or at least, whether there is anything besides the dot, bracketed classes (including extended, which I did not check before but which also do not issue a warning) and the POSIX classes \p{...} and \P{...}.

And just as a side observation, /\b{/ is not a good example of what we're talking about, because that parse fails for a completely different reason -- after the '{' Perl is trying to complete something like /\b{wb}/ and failing.

Thank you all very much.

via perlbug:  queue: perl5 status: open

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