On Monday, 11 September 2023 at 20:17:09 UTC, H. S. Teoh wrote:

Someone should seriously come up with a way of eliminating the repeated type name in default parameters.

Why not allow it to be flexible enough by using a template parameter?

```d
enum Options : bool
{
  silenceErrorsOff, silenceErrorsOn
}

struct Opts
{
  bool silenceErrors;
}

void someFunction(T)(T option = T())
{
  import std.stdio;
  writeln(cast(bool)option); // true
}

void main()
{
  Opts o;
  someFunction(o.silenceErrors = true);

  with(Options)
  someFunction(silenceErrorsOn);
}
```
SDB@79

Reply via email to