Multiple return values...

Timon Gehr timon.gehr at gmx.ch
Sun Mar 11 12:36:00 PDT 2012


On 03/11/2012 07:58 PM, Andrei Alexandrescu wrote:
> On 3/11/12 7:52 AM, Timon Gehr wrote:
>> It is extremely obvious how multiple return values should work.
>
> (int, int) fun();
>
> writeln(fun());
> auto a = fun();
> writeln(a);
>
> What should happen?
>
>
> Andrei
>

That largely depends on fun.
For instance, if it terminates without side effects and always returns 
(1,2), then the program output should be:
12
12

This is already given by the current language semantics:

writeln(tuple(1,2).expand);
auto a = tuple(1,2).expand;
writeln(a);


More information about the Digitalmars-d mailing list