DIP32: Uniform tuple syntax

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Mar 29 03:48:48 PDT 2013


On 3/29/13, kenji hara <k.hara.pg at gmail.com> wrote:
> http://wiki.dlang.org/DIP32
>
> Kenji Hara
>

<quote>
And, this syntax (currently it is not enough documented)
foreach (x, y; zip([1,2,3], ["a","b","c"])) {}
</quote>

Well that kinda sucks, I was just getting used to this syntax..But for
me it it was too magical to begin with, so I have no real complaints.

<quote>
if (auto {1, y} = tup) {
    // If the first element of tup (tup[0]) is equal to 1,
    // y captures the second element of tup (tup[1]).
}
</quote>

That looks like black magic to me.

<quote>
int x = 1;
if (auto {$x, y} = coord) { ... }
// If the first element of coord is equal to 1 (== x), 'then'
statement wil be evaluated.
</quote>

I really don't think we need this magic.. It feels like D and Perl had
lots of booze and made it to the mile-high club, and one of them got
pregnant.

I just thinks this adds way too many features at once. I'd argue we
should take it slow and start with some basic ability to define and
unpack tuples, and then gradually add these other features *if*
they're really wanted.

The new meaning of $ and $var and literals in if statements and "...",
is just too much for me to take.


More information about the Digitalmars-d mailing list