DIP54 : revamp of Phobos tuple types

Dmitry Olshansky dmitry.olsh at gmail.com
Tue Dec 24 02:08:35 PST 2013


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


More information about the Digitalmars-d mailing list