int x = auto

Nick Treleaven nick at geany.org
Wed Mar 22 12:49:23 UTC 2023


On Wednesday, 22 March 2023 at 08:51:27 UTC, Max Samukha wrote:
> On Wednesday, 22 March 2023 at 08:31:46 UTC, Ogi wrote:
>
>> void fun(
>>         int x = auto,
>
> No need for new syntax. It should just be `auto x = 0` or `auto 
> x = int.init` like any other variable declaration.

If the enum type inference DIP was accepted and extended to all 
types, you could write:

int x = $init;

(Or with some other sigil, ?init maybe).
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1044.md

The advantage is it's easier to read function signatures because 
parameters without default arguments have the parameter type on 
the left, not the right. So it's more consistent.


More information about the Digitalmars-d mailing list