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
Deprecate (or change) /$empty_string/ #15359
Comments
From @cpansproutIt often comes up on the list that /$foo/ is subject to re-use of the last match if $foo is empty, and most people then admit that it was a mistake, and that the last match should be used only when the // is syntactically empty. (I believe we have consensus on this, but I may be mistaken.) Because of backward-compatibility, we cannot simply change it, but we could emit a deprecation warning whenever /$foo/ uses the last successful match. I suspect this will catch many bugs in people’s code. After the deprecation cycle, we can make /$foo/ behave the same way as /(?:$foo)/. -- Father Chrysostomos |
From @cpansproutOn Wed May 25 21:55:41 2016, sprout wrote:
I forgot to mention. Anyone who intentionally wants /$foo/ to use the previous match will also get the deprecation warning and change the code to do it some other way. That said, we might want to change /$foo/ without a deprecation cycle, since almost every use of it to mean last-successful-match is probably a bug. This should probably be done early in the dev cycle. In ticket #128225, Yves Orton wrote:
Are you referring to the removal of // as referring to the last successful match? I am strongly opposed to that, but I don’t mind changing /$foo/-as-last-match, without a deprecation cycle, if we do it soon. -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From @demerphqOn 26 May 2016 01:01, "Father Chrysostomos via RT" <
Yes.
Ok. But
|
From @demerphqOn 26 May 2016 10:45, "demerphq" <demerphq@gmail.com> wrote:
We should definitely deprecate it and then remove it (for real). Fwiw have you ever used it or seen it used?
Yeah. I agree that is less controversial. Fwiw One problem i have with this misfeature is that the pattern to split
|
From @AbigailOn Thu, May 26, 2016 at 04:50:04PM +0200, demerphq wrote:
I've seen it used, and I have used it myself. Having said that, I personally, am not going to miss it if it But I'm neutral on the question whether it should be removed. Abigail |
From @demerphqOn 26 May 2016 11:59 a.m., "Abigail" <abigail@abigail.be> wrote:
Interesting. Would i be correct in thinking the place you saw it used was
|
From @apPersonally: • I agree /$empty/ should be deprecated. • I oppose changing its behaviour without a deprecation cycle. • I would enjoy seeing // as “last successful pattern” gone entirely Consider that qr// already does not mean to use the last successfully At that point, the special case is so well circumscribed that I see Regards, |
From @AbigailOn Thu, May 26, 2016 at 07:39:07PM +0200, demerphq wrote:
It's been a long time ago since I saw it, so I'm hazy on the details, I have used // (not inside s///) myself, although I cannot remember Abigail |
From @SmylersAristotle Pagaltzis writes:
“Warning: We've found a bug in your code. Please fix it now, otherwise a
Would it have advantages for users of the identically spelt // Smylers |
From @ap* Smylers <Smylers@stripey.com> [2016-05-27 11:21]:
“Warning: we’ve found behaviour in your code that is almost certainly Although this does raise a very good point: how? In previous threads (At which point it becomes conceivable to eventually remove the special
a) Just taking your questions at face value – I don’t think so. Have you I am not aware of any context where // is ambiguous as to whether it b) Your questions seem moot in the first place, though. Are you proposing to make // not even parse as a match literal at all If you merely wanted to remove the special case behaviour entirely, Regards, |
From @AbigailOn Fri, May 27, 2016 at 09:43:30AM +0100, Smylers wrote:
That seems unlikely. I don't see any obvious way to get Perl confuse a Abigail |
From @SmylersAristotle Pagaltzis writes:
Well it isn't really fix; it's more like make a change in order to keep
Except the bug hasn't been fixed yet, so it'd make more sense to Most deprecation cycles are to give users advance warning of a change That seems like more hassle on users than a typical deprecation warning. Is that really worth it for the sake of genuine uses of /$empty/, who we
if ($pattern eq '') { // } else { /$pattern/ } Not elegant, but it is at least possible (so long as literal //
Fair enough.
I can't remember doing — but then I generate coding errors with
I think it's well within my bounds of ineptness to mistakenly turn a my $variable = some_long_function_name($with, $various, $args); into this: my $variable = some_long_function_name($with, $various, $args); while initially failing to remove the semicolon at the end of the first Currently that yields the error message: String found where operator expected at slash_slash line 4, Whereas using || instead of // (to get an idea of the type of error syntax error at bar_bar line 5, near "||" The // message is a little confusing, in that it's complaining about a
I'm not proposing anything; I was simply wondering whether there are any Smylers |
From @ap* Smylers <Smylers@stripey.com> [2016-05-27 13:39]:
D’oh.
Yeah, awkward.
The reason for my discomfort is that this change in behaviour can easily But you are right that it’s less than obvious how to do this coherently. Hmm. Regards, |
From zefram@fysh.orgAristotle Pagaltzis wrote:
"int // - $z" could be parsed as either "int(// - $z)" or "int() // -zefram |
From @iabynOn Fri, May 27, 2016 at 02:03:05PM +0200, Aristotle Pagaltzis wrote:
Another possibility is to change the behaviour now, but also warn 1. The user's code is currently buggy (it expects /$empty/ to be like /(?:)/) Formerly their code would quietly fail; in future their code will noisily 2. The user actually wanted the 'last regex' behaviour on /$empty/: Formerly, their code worked; And just to recap, IIUC, the current proposal for this ticket is to; 1) leave literal // with its 'last regex' behaviour for now. -- |
From @demerphqOn 11 Jul 2016 10:13, "Dave Mitchell" <davem@iabyn.com> wrote:
I would like to deprecate it in m// but keep it in s/// where it at least
|
From @cpansproutOn Mon Jul 11 07:39:18 2016, demerphq wrote:
I would prefer to keep it in both, since it makes it simpler to explain. -- Father Chrysostomos |
From @cpansproutOn Mon Jul 11 07:13:28 2016, davem wrote:
I think that sounds like a good idea. Are you volunteering? :-)
Yes, that was the idea. -- Father Chrysostomos |
From @iabynOn Mon, Jul 11, 2016 at 08:35:18AM -0700, Father Chrysostomos via RT wrote:
Yes, but not immediately. -- |
From @ap* Father Chrysostomos via RT <perlbug-followup@perl.org> [2016-07-11 17:36]:
I went back and forth over this a bit. My initial inclination was the same as yours: the less special a special But when I imagined making that claim, I realised it doesn’t really help And in a way it could even be easier to understand and explain if the But my next realisation was that we’re not in a vacuum: code may have to So ultimately I think adding reuse-last-pattern as a special feature of Regards, |
From @demerphqOn 11 Jul 2016 11:27 a.m., "Father Chrysostomos via RT" <
Well, I think the "simpler to explain boat" has long since sailed for regex And I think there is a tension here, between making m// consistent in What I mean by this is I think it is easier to explain a difference between I actually think we should deprecate this special behavior entirely and I am really unconvinced by back-compat arguments related to this, I can see little to no value to using this feature in m//, except perhaps On the other hand, there is some tiny advantage in being able to do if (/$complex_pattern1/ or /$complex_pattern2/ or /$complex_pattern3/) { So if we are not to deprecate some part of this behavior it would be to By the way, this is not a new position for me. I have been wanting to get Yves |
Migrated from rt.perl.org#128241 (status was 'open')
Searchable as RT128241$
The text was updated successfully, but these errors were encountered: