Multiple return values...

Manu turkeyman at gmail.com
Fri Mar 9 17:18:10 PST 2012


On 10 March 2012 02:10, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 03/10/2012 01:00 AM, Manu wrote:
>
>> On 10 March 2012 01:17, Timon Gehr <timon.gehr at gmx.ch
>> <mailto:timon.gehr at gmx.ch>> wrote:
>>
>>    On 03/10/2012 12:02 AM, Manfred Nowak wrote:
>>
>>        Manu wrote:
>>
>>            I'm just talking about the ABI for returning multiple
>>            values, not
>>            chaining
>>
>>
>>        Does this mean, that you want a special type of "function"? For
>>        example
>>        this would be disallowed statement: `auto result= f( g(
>>        parameters));',
>>        if `f' and `g' are functions returning multiple values?
>>
>>
>>    This needs to work. Multiple return values should integrate with the
>>    existing language support for tuples.
>>
>>
>> What should that do exactly? A function that returns multiple values is
>> passed as an argument to another function... what exactly is fed to
>> which arguments of the outer function?
>>
>
> It would work like built-in tuples already do.
>
> (int, int) foo(int a, int b){return (a,b);}
>
> assert(foo(foo(foo(foo(1,2))))**==(1,2));
>
> (int, int) goo(int a, int b, int c){return (a+b, c);}
>
> assert(goo(foo(2,3),1) == (5,1));
>
>
>
>  Describe how you see multiple return values working through tuples,
>> while satisfying the issues I raise in my first couple of posts?
>>
>
> I have done so in my other post, you may refer to that one if something is
> still unclear: http://forum.dlang.org/post/**jjdhdk$16v3$1@digitalmars.com<http://forum.dlang.org/post/jjdhdk$16v3$1@digitalmars.com>
>

Right, that all looks good.
But I'm unclear of the language semantics, is this built-in a tuple
actually a physical struct like phobos Tuple, or is it strictly a higher
level concept?
I didn't realise such a thing as 'built-in tuple' existed, why does phobos
Tuple exist?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120310/607a025c/attachment.html>


More information about the Digitalmars-d mailing list