Enhancing of deprecation feature

Andrey Zherikov andrey.zherikov at gmail.com
Thu Nov 4 04:19:35 UTC 2021


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")`.


More information about the Digitalmars-d mailing list