-
Notifications
You must be signed in to change notification settings - Fork 584
Deprecate smartmatch #20337
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 smartmatch #20337
Conversation
The changes to autodie and to the Test-Simple and experimental.pm tests have to be done on CPAN. |
I wonder if it would be best to do those first in a separate |
I don't think we should do this until we have a CPAN module that can largely drop-in replace the core functionality (I don't think it even has to be 100%). I think it's entirely feasible to do this for given/when (I mean, it would largely just be adopting a few chunks code from core). Doing the same for |
I know. I made the changes in the branch to try and get the test suite to pass. The current version of the branch has one test failing, and I don't understand why:
|
The gist of this PR is basically The changes to The actual removal can be done at a later stage (if ever). |
An observation and some questions: CI is reporting a porting test failure, which I reproduced locally. I believe it can be fixed with
In blead, I don't see it anywhere.
Where is its "core" implementation? |
I don't think it was discussed very deeply anywhere. We originally tried just using the normal
...
It won't be anywhere currently. |
Yup, I forgot to rerun it after my last modification and rebase. Expect another force push soon.
We discussed this briefly in a PSC meeting. @leonerd said something about having wanted it in the past, but never actually doing it. The It was said on p5p that some were knowingly using smartmatch in a controlled way, knowing its flaws. (I haven't been able to find that email back, so I might have imagined it?) We felt that it would make sense to make it a bit more fine-grained than simply having it covered by the The relevant p5p threads are:
Creating the This has the interesting side effect that the
|
You say deprecated, but do you actually mean deprecated or just discouraged? I don't think it's a good idea for |
We actually mean "deprecated". And this clearly says that the next step (at a yet undetermined point in the future) is to remove smartmatch entirely.
I agree with you: Which means my patch against |
I agree; anyone who is using |
I think the next steps are:
|
But that does mean end-users will have to change their code twice to keep it working. That's not very end-user friendly. |
It's more about giving users ample warning that smartmatch is going away. Changing It's a bit more difficult to change code using smartmatch to code not using it; on the other hand, that's a change one can make as soon as they see the deprecation warning. So, best case, they only need to change their code once, to remove smartmatch as soon as we announce it's deprecated. |
This seems to be carving out a special type of deprecation that isn't really deprecation, because we don't plan on actually removing it. If we want to deprecate it, lets just do it normally, without a special category. If we aren't willing to commit to removing it, it should be stabilized. |
My understanding is the special type of deprecation is because of the unique circumstances around the feature and its use. Removal is not specifically planned yet but it is meant to indicate that it's a possibility. |
(specifically, removal shouldn't be entertained until sufficient features are present in the language to replace its use, and removal can then be evaluated) |
I understand that smartmatch has a unique history, but I still don't think that justifies this special case. If we don't have a specific plan and schedule for removing smartmatch, we shouldn't deprecate it. |
I agree that we should either remove smartmatch or not deprecate it. We shouldn't deprecate it without a plan to turn it off. "We actually turn things off that we deprecate" was a significant decision some years ago. If we're going to turn it off, it sounds like that's entirely because we think it's a footgun and not because it's currently preventing major progress on the language. If that's the case, we should get a sense of how much of CPAN would break (putting aside the darkpan question for now). I think we can run smokes against this branch and count warnings, or against a version of this branch that fatalizes the warning, and catch errors. |
This new batch of commits follows the PSC decision to deprecate smartmatch in Perl 5.38, and remove it in Perl 5.42. As before the last three commits are there to make the test suite pass, and should be pushed upstream before merging this. |
I can help with this. We are in fact tracking releases via https://github.com/pjf/autodie does autodie have a pull request you need merged? |
I'll make one today. I postponed because I wasn't sure where to send it. |
autodie 2.35 is on CPAN and I have submitted a sync here. If you have any issues, please let me know and we can sort it! |
I have merged to blead. You should be able to rebase and no longer need to modify autodie |
Make the 'experimental::smartmatch' warning obsolete, and use 'deprecated' instead.
I rebased and resolved conflicts on this. |
Thanks. I believe this is ready to be merged, now that the dual-life modules have all been updated. |
regen/feature.pl has been re-run since
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
FWIW, some folks would say we are in the contentious code freeze period. I personally would disagree, and waiting another release cycle would not be helpful. |
On Fri, Feb 24, 2023 at 08:49:39AM -0800, Yves Orton wrote:
Merged #20337 into blead.
cpan/autodie/t/exceptions.t is producing a bunch of warnings. Wasn't this
supposed to be been sorted by pulling in autodie 2.36?
$ ./perl -Ilib cpan/autodie/t/exceptions.t
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 25.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 26.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 27.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 28.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 45.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 46.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 47.
Smartmatch is deprecated at cpan/autodie/t/exceptions.t line 48.
ok 1 - Exception thrown
...
…--
In England there is a special word which means the last sunshine
of the summer. That word is "spring".
|
|
@iabyn @toddr - I have gotten to the bottom of it, PR coming up. The issue is that @toddr assumed that "deprecated::smartmatch" was a valid warning category. But until my PR is pushed and merged we actually dont support this at all, and dont even have a way to, as we only have a single category "deprecated" and the data structure doesnt support us turning it on AND having a sub category. I have a fix in hand already |
The initial PR added a |
I didn't really assume anything about |
The problem with autodie is not really that it is using the wrong category. The problem is that it uses and tests for smartmatch. It needs more extensive changes. I've begun working on fixing it. |
I've prepared Dual-Life/autodie#117 which adjusts autodie to use the correct warning category, but also to deprecate its own smartmatch handling. |
Ok. So I don't jump the gun, is it ready for release? have we solidified how the perl side will work? |
This is a follow-up from http://nntp.perl.org/group/perl.perl5.porters/264678.
This pull request replaces
experimental::smartmatch
bydeprecated::smartmatch
.The goal is to be more explicit that smartmatch is a failed experiment, and its
use is discouraged.
This also remove some uses of
~~
in the core code.