How to deprecate member function from outside?

Neia Neutuladh neia at ikeran.org
Sat Dec 22 19:20:29 UTC 2018


On Sat, 22 Dec 2018 18:55:47 +0000, Dru wrote:
> I would like to use "deprecated" on a member function, but do it from a
> separate file
> 
> this works:
> ///
> void func() {}
> 
> deprecated {
>    void func();
> }

You're defining two functions, presumably in two different modules and 
with two different fully qualified names. One function is deprecated but 
has no body, so you will get a deprecation warning and a linker error if 
you try using it. One function is not deprecated and has a body, so you'll 
get no errors if you try using it.

If, on the other hand, you define both the non-deprecated and deprecated 
functions in the same file, and you try using them, you'll get an error 
saying that the function call matches multiple functions.


More information about the Digitalmars-d-learn mailing list