Automatic variable declaration

Nick Treleaven nick at geany.org
Wed Aug 15 18:55:00 UTC 2018


On Wednesday, 15 August 2018 at 16:56:39 UTC, Everlast wrote:
>>> foo(int x = 3);
>>> foo(auto x = 3);
> If one has to declare the type it reduces it's effectiveness.

auto is not a type ;-) Having e.g. auto or a type makes it clear 
that a new variable is being defined. I'd like this to work 
inside a parenthesized expression too, not just for function 
calls.

> since D can infer the type from the function

I think this would complicate function overload resolution. If an 
initial value is required the type can be inferred from that, 
then no changes are needed to overload resolution.



More information about the Digitalmars-d mailing list