digitalmars.dip.ideas - Deprecated parameters
- user1234 (35/35) Nov 09 For now the grammar does not allow
- Serg Gini (18/22) Nov 09 what the difference with this:
- Atila Neves (2/26) Nov 11 I was going to ask the same thing.
For now the grammar does not allow ```d void v(int a, deprecated int b = 0); ``` I propose to modify [the grammar](https://dlang.org/spec/function.html#ParameterAttributes) to allow this code: ```diff ParameterAttributes: ParameterStorageClass UserDefinedAttribute ParameterAttributes ParameterStorageClass ParameterAttributes UserDefinedAttribute + deprecated? ``` Deprecated parameters will be checked during the semantics verification of the CallExp, passed the stage of overload resolution, following two simple rules 1. It is an error to use the attribute if a default argument is not specified (alternatively can be implemented during dsymbolsem). 2. A new message is output if deprecations are enabled and if a custom argument is passed to the attributed parameter. The new message can be either a warning or an error, according to the matching CLI option (-dw or -de). The message points to the argument, not the parameter. ```d void v0(int a, deprecated int b); // rule 1, error void v1(int a, deprecated int b = 0); // rule 1, no error v1(0); // rule 2, no message v1(0,123); // rule 2, new message for `123` ``` The goal of this enhancement is to propose a system so that users of a library can prepare to a future API change. Is that worth ? Not sure 🤔 but at least the idea is documented now.
Nov 09
On Monday, 10 November 2025 at 07:13:18 UTC, user1234 wrote:For now the grammar does not allow ```d void v(int a, deprecated int b = 0); ```what the difference with this: ```d import std; void v1(int a) { writeln("new"); } deprecated("use v1 with only 1 parameter a") void v1(int a, int b) { writeln("old"); } void main() { v1(0); v1(0, 123); } ```
Nov 09
On Monday, 10 November 2025 at 07:27:55 UTC, Serg Gini wrote:On Monday, 10 November 2025 at 07:13:18 UTC, user1234 wrote:I was going to ask the same thing.For now the grammar does not allow ```d void v(int a, deprecated int b = 0); ```what the difference with this: ```d import std; void v1(int a) { writeln("new"); } deprecated("use v1 with only 1 parameter a") void v1(int a, int b) { writeln("old"); } void main() { v1(0); v1(0, 123); } ```
Nov 11








Atila Neves <atila.neves gmail.com>