www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Enhancing of deprecation feature

reply Andrey Zherikov <andrey.zherikov gmail.com> writes:
Is it possible to enhance the deprecation mechanism that we 
currently have through `deprecated` attribute in a way that the 
source code can provide how the caller should look like to 
migrate off the deprecated API? Something like this:
```d
void bar(string param)
{
}

deprecated("Use bar", (string[] args) => ["bar(", args.join(", 
"), ")"].join)
void foo(string param)
{
     bar(param);
}

foo("text");  // Deprecation: function `foo` is deprecated - Use 
bar:
               // bar("text")
```

Then DMD can have a special mode where it replaces deprecated 
code in place allowing easy migration to newer API, so 
`foo("text")` is substituted with `bar("text")`.
Nov 03 2021
parent zjh <fqbqrr 163.com> writes:
On Thursday, 4 November 2021 at 04:19:35 UTC, Andrey Zherikov 
wrote:
 Is it possible to enhance the deprecation mechanism that we 
 currently have through `deprecated` attribute in a way that the
Good Idea ,helps auto patch into `new version`.
Nov 03 2021