The type inference everywhere

Ali Çehreli acehreli at
Sun Oct 31 17:35:35 UTC 2021

On 10/31/21 7:07 AM, Salih Dincer wrote:
 > ```d
 > auto foo(int value, auto s = Section(2, 60)) {
 >     int max;      /*   ^------- ?
 >     ...            */
 >     return Section (0, max)
 >   }
 > ```
 > Is possible something like above pointed. OK, I know it isn't because I
 > tried! Well, wouldn't it be nice if it did?

Makes sense because e.g. the following works:

struct S {
   auto i = 42;

I bet the problem with your proposal is "auto" in that position is a 
part of the two-word "auto ref" parameters. I don't know how hard or 
impossible it would be to allow just "auto" there.

In any case, although it would be nice for completeness, the use case is 
so rare that I wouldn't mind repeating the type twice in that usage. But 
I agree with you...


More information about the Digitalmars-d-learn mailing list