Optional extra return value? Multiple return values with auto?

ReneSac reneduani at yahoo.com.br
Tue Aug 14 17:37:30 PDT 2012


Thanks, this indeed works. One "obvious" (when your program 
starts to behave weirdly...) down side of this solution: it needs 
a different dummy for each optional out value of a function, or 
else multiple variables will be modifying the same dummy.

And, of course, a different dummy for each type of out value, 
because values after cast() apparently aren't lvalues.

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?

Also, the function duplication workaround doesn't works if I 
templatize the function... Is this inconsistency intentional?


On Saturday, 11 August 2012 at 23:23:48 UTC, Ali Çehreli wrote:
>
> I am not a fan of this solution either. To make the code to 
> compile, define dummy as static:
>
>     static T dummy = T.init;  // <-- this works
>
> That way there will be just one copy for the entire type, 
> instead of one copy per object.
>
> Ali


More information about the Digitalmars-d-learn mailing list