Variadic grouping
John Colvin
john.loughran.colvin at gmail.com
Sat Aug 10 10:08:54 PDT 2013
On Saturday, 10 August 2013 at 12:40:55 UTC, JS wrote:
> On Saturday, 10 August 2013 at 10:19:34 UTC, John Colvin wrote:
>> On Monday, 29 July 2013 at 13:23:23 UTC, JS wrote:
>>> Sometimes it's nice to be able to have groups of variadic
>>> parameters:
>>>
>>> template t(T1..., T2...)
>>>
>>> ...
>>>
>>> t!(a, b, c; d, e, f);
>>>
>>> so that a,b,c are for T1 and d,e,f are for T2.
>>>
>>> This can be done by making a symbol and breaking up a single
>>> variadic but is messy.
>>>
>>> I doubt such a feature will ever get added but who knows...
>>
>> I was initially unimpressed, but after some recent work I would
>
> And this is why just because something looks "unimpressive" to
> you doesn't mean it is... Obviously if you've never run up
> against the specific problems proposed by people you won't know
> how frustrating it is, specially when there is an easy fix.
> This is why those commie bastards that shoot suggestions down
> at first sight ruin progress... they don't have the experience
> with the specific issue to know just how much it sucks.
That is laden with assumption.
I had run in to the problem before, several times. I was not
initially convinced your suggestion was a good idea, especially
after monarch dodra posted Group. After some more experience and
thought I have now changed my mind.
Anyway, never mind all that, what matters is the proposal.
I think this proposal is a good idea, or at least that there
should be some simple syntax for doing this sort of thing. In
particular I'd be interested in hearing from bearophile about how
it might fit in with his wider ideas on tuples and syntax for
packing/unpacking.
Also, are there any corner cases that haven't been considered.
alias T = Tuple!(int, int);
alias Ts = Tuple!(T, T);
template A(S0..., S1...)
{
alias s0 = S0;
alias s1 = S1;
}
A!(Ts.init).s0 a;
what types are a/s0 and s1?
s0 == Tuple!(int, int) == s1
or
s0 == Tuple!(Tuple!(int, int), Tuple!(int, int))
and s1 is an empty tuple
i.e. what will the rules for auto-expansion/unpacking be?
More information about the Digitalmars-d
mailing list