A Discussion of Tuple Syntax

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Aug 21 09:59:17 PDT 2013


On 8/20/13 8:25 PM, Michel Fortin wrote:
> On 2013-08-21 00:38:30 +0000, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> said:
>
>> 1. What do we need?
>
> I think D needs less tuples. It has two kinds (language kind and
> Phobos's kind), which is confusing. It should have just one that covers
> most use cases.

Yah, fewer tuples (or assigning distinct names to what we call today 
such) would be awesome.

> So in essence a tuple should:
>
> 1. be able to contain anything you can put as a template argument

I'm unfortunately lost already. I was discussing tuples as in "anonymous 
structs", not as in "template tuples".

So I'll skip most of what follows, except:

>      int a, b, c, d, e, f;
>      swap(...(a, c, e), ...(b, d, f));
>
> (Note: using "..." syntax to create packed tuple literals. See my other
> post about how that'd work.)

This looks like an example taken from a book in which "..." means some 
stuff is omitted.

This thread has a few odd choices of syntax, but this is awful, pure and 
simple. How in the world could we use "..." which has already a strong 
literary connotation, for an operation? How could one deem

    swap(...(a, c, e), ...(b, d, f));

superior to

    swap(pack(a, c, e), pack(b, d, f));

, particularly considering that "pack" could be replaced with a more 
informative word or combination of words?

Sigh.


Andrei



More information about the Digitalmars-d mailing list