24-Dec-2013 04:57, bearophile пишет:
Andrei Alexandrescu:
It often does make code shorter.
It also avoids the programmer to think about useless details, leaving
more brain for more important things. Assigning the fields to variables
like this:
const uselessTmp = foo();
immutable something = uselessTmp[0];
immutable secondThing = uselessTmp[1];
const theLast = uselessTmp[2];
is as efficient as leaving that to the compiler.
Agreed. IMHO destructuring of structs, tuples and arrays is something we
ought to have at some point.
Something not unlike ECMA Script:
http://wiki.ecmascript.org/doku.php?id=harmony:destructuring
http://wiki.ecmascript.org/doku.php?id=proposals:destructuring_assignment
Bye,
bearophile
--
Dmitry Olshansky