I dun a DIP, possibly the best DIP ever

Walter Bright newshound2 at digitalmars.com
Fri Apr 24 08:35:53 UTC 2020


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);
   }


More information about the Digitalmars-d mailing list