2013/3/29 Dmitry Olshansky <[email protected]>

> A few typos like:
> {c, $} = tup;   // Rewritten as: a = tup[0];
> where it should be //Rewritten as c = tup[0];
>

Thanks. Fixed.


> About swapping values by tuple assignment.
>
> Why not simply make this work:
> {x, y} = {y, x}
>
> By lowering
> {x, y}  = {y, x};
> to
> auto temp0 = y;
> auto temp1 = x;
> x = temp0;
> y = temp1;
>
> And let the compiler do value propagation to remove the extra temp0.
>

Because it already exists.

template Seq(T...) { alias Seq = T; }
void main()
{
    int x = 1, y = 2;
    Seq!(x, y) = Seq!(y, x);    // tuple assigmnent
    assert(x == 2);
    assert(y == 2);
}

Another note - is there any way to extend this notation to common structs
> other then .tupleof ? I think we may hopefully extended it later towards
> struct destructruing a-la EcmaScript 6, see
>
> http://wiki.ecmascript.org/**doku.php?id=harmony:**destructuring<http://wiki.ecmascript.org/doku.php?id=harmony:destructuring>


Hmm, interesting. I'll see it later.

Kenji Hara

Reply via email to