Yet another MRV proposal!

Hans W. Uhlig huhlig at gmail.com
Fri Apr 18 13:12:22 PDT 2008


Leandro Lucarella wrote:
> downs, el 14 de abril a las 11:23 me escribiste:
>> Let's give this another try.
>> The following proposal has the advantage that it's funded mostly on existing syntax.
>>
>> An anonymous struct, in the position where you'd normally expect a function/method return type, is usable as the return type instead.
>>
>> Example:
>>
>> struct { int a; float b; } test() { return(1, 2f); }
>>
>> writefln(test().a, test().b);
> 
> I think what you really want here is to return a tuple. I think adding
> tuples to the language/library would be much more elegant. For example:
> 
> (int, float) test() { return (1, 2f); }
> 
> writefln(test()[0], test()[1]);
> 
> (I know the syntax it's no good, I wanted just to expose the concept).
> 

I think adding them to the core of the language would be better then 
making a library hack.



More information about the Digitalmars-d mailing list