DIP32: Uniform tuple syntax

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Mar 29 02:44:48 PDT 2013


29-Mar-2013 12:57, kenji hara пишет:
> http://wiki.dlang.org/DIP32
>
> Kenji Hara

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

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.

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

All in all it's a great proposal, I'm loving it.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list