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

Add deprecation subcategories, test deprecations properly including in perldiag and perlderprecation.pod #20916

Merged
merged 18 commits into from
Mar 18, 2023

Conversation

demerphq
Copy link
Collaborator

@demerphq demerphq commented Mar 9, 2023

Currently we use a single warning category for all deprecations. This is dangerous in that it allows a new deprecation to sneak in when the user only wanted to allow a different deprecation, and IMO counterproductive as it means there is no way to know /which/ deprecation someone is silencing in their code and give them good feedback when the feature is no longer supported.

Having only one category essentially says "if you want to risk using a deprecation then you have to risk not knowing about any deprecation", but this does not make sense. Why should I have to take maximal risk when I want to take a known risk?It makes even less sense when you consider we have at least three categories which are long standing and still not scheduled for removal. If a user wants to silence one of these long standing deprecation types they essentially must risk not being informed about any other category at all. That seems unhelpful and unnecessarily risky.

By having all deprecations be subcategorized in regen/warnings.pl we also get some built in support for tracking the version that a deprecation was added, which can then be used to test that our various files provide sufficient dev cycles before they are removed.

It also makes it more obvious that we have unscheduled deprecations that have been around for a very long time, and which will likely always be present (or so it seems).

This PR adds support for deprecation subcategories, it converts all existing deprecations to use subcategories, it fixes the API's of all deprecation related functionality that I could find to require a category, and it ensures that diag.t knows about these functions so it can test the diagnostics produced, it also validates that perldeprecation.pod metions all existing deprecation categories and that they are documented with sufficient version cycles before they are removed.

I understand that the PSC has "decided" that it is a bad idea to have deprecation subcategories. I believe that this decision is wrong, and should not have been made without wider discusion. This patch demonstrates why it is a good idea to have these subcategories. It facilitates testing and documenting the categories, it allows our users to manage their risk at a more granular level, and it allows us quick access as to which deprecations are "live" at any given point in time. The counter arguments that I have seen expressed, for instance here: #20855 (comment) and #20855 do not seem very compelling compared to the advantages enumerated here, and demonstrated by this PR.

Copy link
Contributor

@leonerd leonerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this appears to be going the right way; give or take some minor comments below.

Would appreciate a second opinion from @rjbs or @book first though, to check we're aligned with today's re-thinking on PSC.

handy.h Outdated Show resolved Hide resolved
regen/warnings.pl Outdated Show resolved Hide resolved
t/porting/deprecation.t Outdated Show resolved Hide resolved
t/porting/deprecation.t Outdated Show resolved Hide resolved
… category as parameter

we should have a deprecation category per type of deprecation
Currently we seem to lack a way to have a subcategory under deprecated.
It seems reasonable to me that people might want to disable a specific
subcategory warning while leaving the rest in place. This patch allows
that. Note that both

    no warnings "deprecated";

and

    no warnings "deprecated::smartmatch";

work to disable the warning. Deprecated warnings shouldn't be "all or
nothing", they should be specific and targetted.
Instead of using a generic warnings category switch to fine grained
control.
This category is only used in the regex engine, we should be able
to disable it specifically, as it seems like we will never actually
remove demove support for the things it warns about.
…deprecation category

This category is about use of apostrophe as a package separator, eg
for things like "Test::More::isn't()".
Some delimiters are considered deprecated because in the future they
will be used as part of a paired delimiter. This adds a new category
for these cases.
This category applies to attempts to goto the internals of a block
construct.
This also fixes the version_downgrade to show the correct version that
version downgrades will be removed in.
This makes it easier to see the order the categories were added in.
Also do not generate PERL_ARGS style macros for macros.
…cros

the "when" parameter is expected to be a version string of the form "5.\d+",
with no minor version.
This was missed when smartmatch was deprecated.
It was incorrectly documented as going away in 5.40
Multiple deprecation types that are not scheduled for removal in a
specific version were not listed. Also now that we have deprecation
subcategories we should specify them in the docs.
@demerphq demerphq force-pushed the yves/deprecation_subcategories branch from 70c1072 to 0b2570f Compare March 11, 2023 10:46
@demerphq
Copy link
Collaborator Author

@leonerd you said someone objected to this, but nobody has comment on this PR, nor on the thread on p5p. Can you ask them to comment here please?

@demerphq
Copy link
Collaborator Author

We discussed offering split-up deprecation categories, so you can "no warnings 'deprecated::.xyz" and re-affirmed that we want to do this.

Based on the PSC "PSC #101, 2023-03-17" comment above, and the fact noone has raised any objections, I am merging this.

@demerphq demerphq merged commit 0144c00 into blead Mar 18, 2023
@demerphq demerphq deleted the yves/deprecation_subcategories branch March 18, 2023 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants