On Saturday, 10 August 2013 at 17:08:57 UTC, John Colvin wrote:
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.


Well, again, the issue is that it only becomes one once you've actually experienced the problem enough. This is why those that actually haven't even run into the problem shouldn't really have a say so if it is valid or not, unless they can bring some theoretical reason why it is flawed.

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?

The way I see it, using `;` is what separates groups. So in your above code, s1 is empty.

The `;` is shorthand for specifying groups. No where do you specify such a group for A!(...), so there are no groups.

There is no direct way to get your second case under my proposal... unless the compiler was given some additional feature to do so.

e.g.,

alias Ts = Tuple!(T, T);

is not the same as

alias Ts = Tuple!(T; T);

also, we would probably want to use template A(S0...; S1...) instead of template A(S0..., S1...)


The main thing is that `;` adds an extra symbol to split on that is entirely distinct from `,`. If you wanted, you could have Tuple! and TupleSC!. TupleSC! is used when splitting `;`. Tuple! and TupleSC! are not directly related(but can easily be flattened together if necessary.

Reply via email to