Jump to page: 1 2
Thread overview
[Issue 20982] Add a pragma to suppress deprecation messages
Jun 26, 2020
Stefan Koch
Jun 27, 2020
Mike Parker
Jun 27, 2020
Basile-z
Jun 27, 2020
Richard Manthorpe
Jun 27, 2020
Stanislav Blinov
Jun 27, 2020
Mathias LANG
Dec 17, 2022
Iain Buclaw
June 26, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
June 26, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Stefan Koch <uplink.coder@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uplink.coder@gmail.com

--- Comment #1 from Stefan Koch <uplink.coder@gmail.com> ---
perhaps it should be pargma(push, deprecated, false) then.
together with pragma(pop, deprecated)?

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> ---
Another idea from Stefan was to control this programmaticaly:

static if (deprecated(symbol)) {
    ... avoid ...
}

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Mike Parker <aldacron@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldacron@gmail.com

--- Comment #3 from Mike Parker <aldacron@gmail.com> ---
I like:

pragma(mute, deprecation)
// blah
pragma(unmute, deprecation)

This could then be generalized to apply to other specific warnings in future if the need arises.

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #4 from Basile-z <b2.temp@gmx.com> ---
(In reply to Andrei Alexandrescu from comment #2)
> Another idea from Stefan was to control this programmaticaly:
> 
> static if (deprecated(symbol)) {
>     ... avoid ...
> }

this could be a property instead, working on types and symbols and why not everything (to avoid branches in metaprog)

  static if (symbol.deprecated){}

just like, `.tupleof`, `.mangleof`, etc...

But there's also the option that is not to allow abuse just because of one use case and fix the use case instead, concretly: exclude deprecated symbol from __traits(all,Members), if this is only about this. Or Add a 3rd optional parameter to __traits(allMembers), which would be a set of flag, for now only telling if deprecations have to ignored...

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Richard Manthorpe <rmanth@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rmanth@gmail.com

--- Comment #5 from Richard Manthorpe <rmanth@gmail.com> ---
Scoped pragmas using push and pop is definitely the most robust pragma solution. This is a very common pattern in C++ compilers and could be a useful pattern for other things too.

While excluding deprecated symbols from __traits(allMembers) (and presumably also __traits(getOverloads)), or something like a deprecated(symbol) would help avoid accidentally dealing with deprecated code during introspection, there are other cases that I think only the pragma can help with. For example, we have a library that has test cases using creal because we need to know it works with complex primitives for compatibility. We know it's deprecated and we don't need to be told about it all the time.

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Stanislav Blinov <stanislav.blinov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.blinov@gmail.com

--- Comment #6 from Stanislav Blinov <stanislav.blinov@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #2)
> Another idea from Stefan was to control this programmaticaly:
> 
> static if (deprecated(symbol)) {
>     ... avoid ...
> }

Yeah, we can kind of do this already, though it's a mouthful:

    static foreach (name; __traits(allMembers, Foo))
    {
        static if (!__traits(isDeprecated, __traits(getMember, Foo, name)))
        {{
            alias sym = __traits(getMember, Foo, name);
        }}
    }

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

--- Comment #7 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to Stanislav Blinov from comment #6)
> (In reply to Andrei Alexandrescu from comment #2)
> > Another idea from Stefan was to control this programmaticaly:
> > 
> > static if (deprecated(symbol)) {
> >     ... avoid ...
> > }
> 
> Yeah, we can kind of do this already, though it's a mouthful:
> 
>     static foreach (name; __traits(allMembers, Foo))
>     {
>         static if (!__traits(isDeprecated, __traits(getMember, Foo, name)))
>         {{
>             alias sym = __traits(getMember, Foo, name);
>         }}
>     }

Forgot about that, thanks!

--
June 27, 2020
https://issues.dlang.org/show_bug.cgi?id=20982

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #8 from Mathias LANG <pro.mathias.lang@gmail.com> ---
> Yeah, we can kind of do this already, though it's a mouthful: [...]

Using `__traits(isDeprecated)` sounds much more reasonable to me, as it only
apply to one symbol.

Yes it will push some ugliness in user code, but I can completely see `pragma(deprecated, false)` being misused. What happens when the code that does introspection uses a Phobos function that gets deprecated, or even worse, a language feature ?

An improvement on the current state would be a way to filter them out in the
static foreach, a la`static foreach (V; Filter!(isNotDeprecated,
__traits(allMembers, aggr)))`.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20982

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
« First   ‹ Prev
1 2