C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Keeping C++ Young: Migrating to Modern C++

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sun, 5 Nov 2023 07:09:47 -0500
On Sun, Nov 5, 2023, 6:25 AM Yexuan Xiao via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> A name marked as discouraged does not imply that it will be removed in the
> future, it is not a precursor to deprecated. And it conditionally generates
> a warning.
>

This seems like a job for a linter like clang-tidy or PVS-Studio, not for
WG21. If WG21 were convinced that some construct ought to be officially
"discouraged," I see no reason they wouldn't just deprecate it. Or, if you
*can't* convince all of WG21, then you won't be able to apply the
attribute. (Except that a vendor can do it as a conforming extension — but
that's the status quo — you don't need a proposal for that at all!)

Also: most "discouraged" constructions don't correspond to entities that
could have the attribute attached to them. For example, raw new and delete
are discouraged, but are still used inside the implementations of various
third-party library facilities. The use of T(x) syntax for reinterpret_cast
is discouraged, but reinterpret_cast isn't an entity, it's a keyword.
Likewise goto is a keyword, not an entity.
These are all things that a linter can and does warn about. But your
attribute won't help.

HTH,
Arthur


------------------------------
> *From:* Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf
> of Andrey Semashev via Std-Proposals <std-proposals_at_[hidden]>
> *Sent:* Sunday, November 5, 2023 19:18
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* Andrey Semashev <andrey.semashev_at_[hidden]>
> *Subject:* Re: [std-proposals] Keeping C++ Young: Migrating to Modern C++
>
> On 11/5/23 14:11, Yexuan Xiao via Std-Proposals wrote:
> > I propose a new standard attribute, [[discouraged]], and a new macro,
> > #strict, to indicating that the name or entity declared with this
> > attribute is discouraged from use, and giving an alternative.
> >
> > [[discouraged( string-literal )]]
> > string-literal - an unevaluated string literal that could be used to
> > explain the rationale for discouragement and to suggest a replacing
> entity
> >
> > macro #strict
> > #strict can appear anywhere in the file, and once the file contains this
> > macro, the compiler will generate warnings for all uses of names and
> > syntax that are marked as discouraged, and give the reason.
> >
> > Full proposal written with bikeshed here:
> >
> https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapi.csswg.org%2Fbikeshed%2F%3Furl%3Dhttps%3A%2F%2Fstorage.nykz.org%2Fproposals%2Fkeeping-cxx-young.bs%26force%3D1&data=05%7C01%7C%7Cfeeb6e510b0446d4ab3708dbddf0f760%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638347799252785276%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=O6FWAqbou7wxTn4RonkCwP4moduJuZllOOOwFX2kCVY%3D&reserved=0
> <https://api.csswg.org/bikeshed/?url=https://storage.nykz.org/proposals/keeping-cxx-young.bs&force=1>
> <
> https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapi.csswg.org%2Fbikeshed%2F%3Furl%3Dhttps%3A%2F%2Fstorage.nykz.org%2Fproposals%2Fkeeping-cxx-young.bs%26force%3D1&data=05%7C01%7C%7Cfeeb6e510b0446d4ab3708dbddf0f760%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638347799252785276%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=O6FWAqbou7wxTn4RonkCwP4moduJuZllOOOwFX2kCVY%3D&reserved=0
> <https://api.csswg.org/bikeshed/?url=https://storage.nykz.org/proposals/keeping-cxx-young.bs&force=1>
> >.
>
> How is it different from [[deprecated]]?
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
>
> https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&data=05%7C01%7C%7Cfeeb6e510b0446d4ab3708dbddf0f760%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638347799252785276%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RJsZGgHcQ4Np3B%2FWKQfVjNLQOvzLehP3QhodMdqcgJs%3D&reserved=0
> <https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-11-05 12:10:01