int x = auto
Dom Disc
dominikus at scherkl.de
Wed Mar 22 17:58:38 UTC 2023
On Wednesday, 22 March 2023 at 08:31:46 UTC, Ogi wrote:
> Suggestion: allow implicit default-initialization using `type x
> = auto` syntax. This is the same as `type x = type.init` and
> `type x = type()`.
>
> This will be especially handy for functions with optional
> parameters.
>
> Before:
> ```D
> void fun(
> int x = 0,
> double y = double.nan,
> bool flag = false,
> string str = "",
> void* ptr = null,
> SomeStruct t = SomeStruct(),
> int[4] arr = [0, 0, 0, 0])
> ```
After:
```D
void fun(
auto x = int.init,
auto y = double.init,
auto flag = bool.init,
auto str = string.init,
auto ptr = void*.init, // ok, not sure if this works
auto t = SomeStruct.init,
auto arr = int[4].init; // if this doesn't work, we should fix
it
```
So, where is the problem?
More information about the Digitalmars-d
mailing list