Named return type > Out parameters

"のしいか (noshiika)" noshiika at gmail.com
Thu Nov 12 18:57:03 PST 2009


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.

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



More information about the Digitalmars-d mailing list