DIP54 : revamp of Phobos tuple types

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Dec 29 19:44:54 PST 2013


On 12/29/13 6:58 PM, Dicebot wrote:
> On Monday, 30 December 2013 at 00:20:43 UTC, Timon Gehr wrote:
>> What would be an example of code that you consider to be broken?
>> (TemplateArgumentList!(int, double) is a valid type and
>> TemplateArgumentList!(1, 2.0) is a value of that type.)
>
> Stuff that relies that, for example, that `is(TypeTuple!(int, double) ==
> typeof(TypeTuple!(42, 2.0)))`. There is no place in specification that
> defines / guarantees it or even define tuple as a valid type entity (or,
> to be precise, I have been looking for one and failed to find the
> mention). It behaves as if one is the instance of the other but is more
> of coincidence than intended rule.
>
> I also remember Andrei mentioning in one of tuple threads that this
> relation is not supposed to be valid in general but it is very hard to
> find exact comment right now. Andrei can you please either confirm this
> or call me wrong? :)

I don't understand the question. I think there's no particular relation 
between TemplateArgument{List,Pack}!(int, double) and 
TemplateArgument{List,Pack}!(1, 2.0). One is a list of two types and the 
other is a list of two values, and yah, if you map typeof over the 
arguments in the latter it so happens you get the types in the first.

Template arguments lists are what they are - entities that can be passed 
to templates. Aliasing them is sensible but creating values thereof does 
not make sense.

Tuples are a different beast altogether. It would be nice to be able to 
extract their support types as a TemplateArgument{List,Pack} but that's 
about it.

One more word about providing TemplateArgument{List,Pack} vs. only one 
of them. Our users fall into categories such as:

0. Language lawyers who've studied the fine distinctions and are able to 
use either abstraction and define what they need if missing.

1. Experts who have an understanding of what they need and expect, and 
may or may not be surprised by whichever behavior we choose.

2. Users who have only a vague idea what the power is, and would have a 
difficult time using self-expansion when not needed or vice versa.

3. Users who don't know the first thing about the entire notion of 
grouping template arguments together.

I think we'd harm one or more categories of these users if we choose for 
them. We can't win. Conversely, we'd inform and please them all if we 
attacked the matter head on with a combination of 
TemplateArgument{List,Pack} and their afferent documentation.


Andrei



More information about the Digitalmars-d mailing list