On Fri, Apr 24, 2020 at 6:40 PM Walter Bright via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 4/24/2020 1:24 AM, Walter Bright wrote:
> On 4/23/2020 11:00 PM, Manu wrote:
>> I guess this is the key case you need to solve for:
>>
>>    template T(Args...) {}
>>    T!(Tup)     -> T!(0, 1, 2)
>>    T!(Tup)...  -> T!0, T!1, T!2
>>
>> And the parallel expansion disambiguation is also critical:
>>    T!(Tup, Tup2...)...  -> T!(0, 3, 4, 5), T!(1, 3, 4, 5), T!(2, 3, 4, 5)
>>
>> If you can solve those, the rest will probably follow.
>
> Fair enough. Though there needs to be a rationale as to why those two particuler
> cases are needed and critical.

Please keep in mind that the following works today:

   void foo(int);

   template tuple(T...) { enum tuple = T; }

   void test() {
     auto t = tuple!(1, 2, 3);
     static foreach (i, e; t)
         foo(e + i);
   }

and generates:

   void test() {
      foo(1); foo(3); foo(5);
   }

static foreach is not an expression, and it's very hard to involve those result calls in some conjunction. Expand that code to || them together... it gets ugly real fast.
I wouldn't have wasted my time writing this DIP and a reference implementation if static foreach was fine.

Find instances of `staticMap` in phobos and/or user code, and show how you can replace them with static foreach, then there's something to talk about.