On 3/16/12 3:48 AM, Iain Buclaw wrote:
This could also be done for arrays too.

(int a, b) = arr[];

----->

static assert(arr.length == 2);
int a = arr[0];
int b = arr[1];

Yah, the rewrite is purely syntactic, not tuple-specific. That's a major thing I like about it.

Or possibly a use in variadic templates, which could make D act more
like how some scripting languages work.

void conn(T ...)(T args) {
   // vars get default init if value wasn't passed to function.
   (string server, port, username, password) = args[];
}

I fear this is a bit error-prone.


Andrei

Reply via email to