On Friday, 5 October 2012 at 00:39:40 UTC, timotheecour wrote:
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?

Surely the ideal is what you're written but also allowing the omission of parens where it's unambiguous? Just to keep this idea in people's minds:

return 1, "abc";

That would seem like the ideal to me as would:

double, string fun(double, double n) {
    return n[0] * n[1], "abc";
}

Should these uses require parens like this?

(double, string) fun((double, double) n) {
    return (n[0] * n[1], "abc");
}

As discussed before the parens are unavoidable for assignment given the need to avoid breaking vast quantities of code.

Reply via email to