DIP54 : revamp of Phobos tuple types

Dicebot public at dicebot.lv
Mon Dec 23 05:31:35 PST 2013


On Monday, 23 December 2013 at 13:23:39 UTC, monarch_dodra wrote:
>> 5 Algorithms from `std.typetuple` are re-written to accept 
>> non-expanding template argument lists and form base for 
>> `std.meta.` package.
>
> Why? This seems to me like it would create duplication for 
> nothing. These templates would do the expanding themselves?

Consistency of function signatures. Final goal is to have 
std.meta.* templates to be as similar as possible to their 
std.algorithm / std.range counterparts.

There won't be any duplication, old templates get deprecated.

> Unless I'm mistaken, the `TemplateArgumentList`represents a 
> packaged and convenient to use type. You only unpack it when 
> you actually pass around the types.

> If anything, this would create ambiguity. If the algorithms 
> from typetuple accept a TemplateArgumentList, and expand it 
> themselves, then we'd be creating ambiguity:

You only unpack (expand is proper term) it if you need to convert 
it to raw parameter list. You are expected to operate on it 
without any expansion on most other cases. Algorithms don't need 
to expand it either.

(And thanks Timon for an awesome "alias this" hint to achieve 
that)

> eg:
> staticIndexOf(int, TemplateArgumentList!(int, double), int);
>
> Produces 1? 2? 3?
> I really don't know.

Compile-time error, new `staticIndexOf` will strictly accept 2 
template arguments - element and the list, similar to normal 
`indexOf`:

template staticIndexOf(T...)
     if ((T.length == 2) && isTemplateArgumentList!(T[1]))


> I think TemplateArgumentList should be handled as what it is: a 
> *type*, and not unpackaged by clients receiving the type, but 
> by providers of the type.

It does not need to expanded at all in most cases :)


More information about the Digitalmars-d mailing list