Optional extra return value? Multiple return values with auto?

ReneSac reneduani at yahoo.com.br
Wed Aug 15 08:38:44 PDT 2012


On Wednesday, 15 August 2012 at 01:22:41 UTC, Era Scarecrow wrote:
> On Wednesday, 15 August 2012 at 00:37:32 UTC, ReneSac wrote:
>> And my last question of my first post: I can't use "auto" for 
>> the "out" values right? An enhancement proposal like this 
>> would be compatible with D?
>
>  I would say.... No. Maybe if it was a union, but I don't think 
> so;.It still needs to know it's type when it's working with, 
> aka statically typed (known at compile-time).
>
>  The auto as an out variable may work in an interpreted or more 
> dynamic language.

It was the reverse way (as in my first post):

bool bar(out ulong output){ output = 0 ; return true;}

auto check = bar(auto num); // error

The type of the out parameter is explicit in this case, but, 
right now, I need to declarate num outside the function, and thus 
I can't use the auto keyword.

I'm not sure how this would work for templatized out parameters 
(if they are permitted)...


More information about the Digitalmars-d-learn mailing list