Feature request: extending comma operator's functionality

timotheecour thelastmammoth at gmail.com
Thu Oct 4 17:33:45 PDT 2012


Is the plan to deprecate comma operator for chaining expressions?
I would love to see more syntactic sugar to support tuples, and 
comma operator would be the best fit for that purpose.

eg:
----
import std.typecons;
auto fun(){
     return tuple(1,"abc");
     //1) ideally, we should be able to write:
     //return (1,"abc");
     //with same semantics (and no need to import std.typecons)
}

//at the call site: currently:
auto t=fun();
auto a=t[0];
auto b=t[1];

//2) ideally, we should be able to write:
auto (a,b,c)=fun();

//3) or even:
(a,b,c)=fun();
----

Will it be difficult to implement 2)? (by far the most important 
of 1,2,3)
Is 1) and 3) a good idea?


More information about the Digitalmars-d mailing list