A Discussion of Tuple Syntax

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Aug 19 13:45:33 PDT 2013


On 8/19/13 12:54 PM, bearophile wrote:
> Meta:
>
>> It *could* be an underscore; the only thing is that the underscore is
>> a valid variable name, so the above expression would actually be
>> binding two variables, which might surprise someone who was expecting
>> otherwise. I don't really care all that much, but it's something to
>> think about.
>
> You can't define a variable more than once in a scope, so this can't be
> valid:
>
> void main() {
>      auto t1 = #(5, "hello", 1.5);
>      auto (_,  _, x) = t1;
>      auto (_, gr, _) = t1;
> }
>
>
> While ? defines nothing, so this is OK:
>
> void main() {
>      auto t1 = #(5, "hello", 1.5);
>      auto (?,  ?, x) = t1;
>      auto (?, gr, ?) = t1;
> }
>
> Bye,
> bearophile

It's stuff like this that's just useless and gives a bad direction to 
the whole discussion. There's hardly anything wrong with auto x = t1[2] 
or auto gr = t1[1], but once the bikeshed is up for painting, the 
rainbow won't suffice.


Andrei



More information about the Digitalmars-d mailing list