Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 22, 2018 How to deprecate member function from outside? | ||||
---|---|---|---|---|
| ||||
Hi, I would like to use "deprecated" on a member function, but do it from a separate file this works: /// void func() {} deprecated { void func(); } //// this doesn't work: //// class C{ void func() {} } deprecated { void C.func(); } //// I get: Error: semicolon expected, not . Thanks |
December 22, 2018 Re: How to deprecate member function from outside? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dru | 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.
|
December 22, 2018 Re: How to deprecate member function from outside? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Neia Neutuladh | Thanks for the reply I will try to explain what I mean: The first example shows that it is possible to deprecate a function separately from it's definition. The second example tries the same for a member function but it fails with a compile error. I want to know if it is possible to "fix" the second example? (deprecate a member function separately from it's definition) |
December 22, 2018 Re: How to deprecate member function from outside? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dru | On Sat, 22 Dec 2018 21:33:14 +0000, Dru wrote: > The first example shows that it is possible to deprecate a function separately from it's definition. No, it doesn't. You declared two *different* functions. One was deprecated; the other wasn't. > I want to know if it is possible to "fix" the second example? (deprecate a member function separately from it's definition) No. All functions must be deprecated where you declare them. |
December 22, 2018 Re: How to deprecate member function from outside? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Neia Neutuladh | You're right it did define two functions same signature and no compile error, heh |
Copyright © 1999-2021 by the D Language Foundation