Named return type > Out parameters

Ellery Newcomer ellery-newcomer at utulsa.edu
Thu Nov 12 20:17:27 PST 2009


のしいか (noshiika) wrote:
> Bill Baxter さんは書きました:
>> Did go do away with the comma sequencing operator?
>> I can't find it.  That's the first thing D needs to do.
>>
>> Otherwise
>>    a,b = function()
>> is difficult to make work.
> 
> How about redefining the comma operator as a "tuple constructor"
> with its precedence unchanged?
> 
> In so doing, we may write:
> 
>   (int, int) func(int x, int y) { return y, x; }
>     // tuple-to-tuple function
>     // (int, int) is a type tuple, "int x, int y" a named type tuple,
>     // and "y, x" an expression tuple.
> 
>   (int, int) t = func(0, 1);
>     // t is a type-tuple-typed variable.
> 
>   int a, b;
>   (a, b) = func(t);
>     // (a, b) is an lvalue tuple.
> 

call me a pascal junkie, but I much prefer being able to write
a,b = b,a;

> and f(0, 1) beautifully has the same semantics with f((0, 1)) by the
> tuple flattening.


In other news, I just ran a search on tango and phobos1, and found comma
operator used 83 and 11 times, respectively. A little less than I expected.



More information about the Digitalmars-d mailing list