Le 25/09/2012 17:51, ixid a écrit :
You've shown it's clearly incompatible with the current language and
would break lots of code. What would it break if assignment required
explicit tuple brackets?

(int a, b) = foo(); // A tuple assignment, 'a' and 'b' will be filled in
order by the multiple return values of foo()

int foo() {
return 1;
}

(int a, b) = foo(); // Also valid and only sets 'a'


int, int foo() {
return 1, 2;
}

int a = foo(); // Also valid and 'a' takes the first tuple value

(int a, auto b) = foo(); // Evaluated left to right so 'a' will take the
first argument of foo and b will auto to a type or tuple of what
remains. It will error if there is nothing remaining for b. This would
still allow the clean expression of stand-alone tuples and function
arguments and return values.

int, string a = 1, "hello";
int, string foo(double, double a) {
return cast(int) (d[0] * d[1]), "hello";
}


WTF are thoses affirmations ?

Reply via email to