September 15, 2016
On 09/14/2016 05:50 PM, Stefan Koch wrote:
> On Wednesday, 14 September 2016 at 21:06:10 UTC, Andrei Alexandrescu wrote:
>> On 09/14/2016 04:52 PM, Stefan Koch wrote:
>>> [...]
>>
>> (Disclaimer: I didn't run any speed tests.) By looking at the
>> definition of fullyQualifiedName it seems to me we can go a long way
>> with traditional optimization techniques. For example consider:
>>
>> [...]
>
> staticMap is number 3 in the top-slow-templates list.
> And the code inside it really does not matter so much.
> What matters is recursive instanciation.
>
> the evaluation of the function is fast in comparison to the time the
> template-subsystem takes.
>
> I believe this cannot be fixed by changing a library solution.

Apparently we need that static foreach iteration. -- Andrei

September 15, 2016
On Thursday, 15 September 2016 at 12:26:08 UTC, Andrei Alexandrescu wrote:
>
> Apparently we need that static foreach iteration. -- Andrei

What exactly do you mean ?
As long as we instanciate n templates for a member nested n levels the overhead is massive!
How would static foreach help ?



September 15, 2016
On 09/15/2016 08:35 AM, Stefan Koch wrote:
> On Thursday, 15 September 2016 at 12:26:08 UTC, Andrei Alexandrescu wrote:
>>
>> Apparently we need that static foreach iteration. -- Andrei
>
> What exactly do you mean ?
> As long as we instanciate n templates for a member nested n levels the
> overhead is massive!
> How would static foreach help ?

I thought staticMap is just a (simulated) loop that applies the same template in sequence. -- Andrei
September 15, 2016
On Thursday, 15 September 2016 at 13:20:16 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 08:35 AM, Stefan Koch wrote:
>> On Thursday, 15 September 2016 at 12:26:08 UTC, Andrei Alexandrescu wrote:
>>>
>>> Apparently we need that static foreach iteration. -- Andrei
>>
>> What exactly do you mean ?
>> As long as we instanciate n templates for a member nested n levels the
>> overhead is massive!
>> How would static foreach help ?
>
> I thought staticMap is just a (simulated) loop that applies the same template in sequence. -- Andrei

staticMap is a recursive variadic template.
CompileTime wise the worst class a template can be in.
it expands to a series of templates instancing itself log(n) times.
causing 2n*log(n) instances in total.

It's not a pretty picture.
September 15, 2016
On 09/15/2016 09:27 AM, Stefan Koch wrote:
> On Thursday, 15 September 2016 at 13:20:16 UTC, Andrei Alexandrescu wrote:
>> On 09/15/2016 08:35 AM, Stefan Koch wrote:
>>> On Thursday, 15 September 2016 at 12:26:08 UTC, Andrei Alexandrescu
>>> wrote:
>>>>
>>>> Apparently we need that static foreach iteration. -- Andrei
>>>
>>> What exactly do you mean ?
>>> As long as we instanciate n templates for a member nested n levels the
>>> overhead is massive!
>>> How would static foreach help ?
>>
>> I thought staticMap is just a (simulated) loop that applies the same
>> template in sequence. -- Andrei
>
> staticMap is a recursive variadic template.

Can recursion be replaced with iteration? Assume you have static foreach at your disposal. -- Andrei

September 15, 2016
On Thursday, 15 September 2016 at 13:49:46 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 09:27 AM, Stefan Koch wrote:
>> On Thursday, 15 September 2016 at 13:20:16 UTC, Andrei Alexandrescu wrote:
>>> On 09/15/2016 08:35 AM, Stefan Koch wrote:
>>>> On Thursday, 15 September 2016 at 12:26:08 UTC, Andrei Alexandrescu
>>>> wrote:
>>>>>
>>>>> Apparently we need that static foreach iteration. -- Andrei
>>>>
>>>> What exactly do you mean ?
>>>> As long as we instanciate n templates for a member nested n levels the
>>>> overhead is massive!
>>>> How would static foreach help ?
>>>
>>> I thought staticMap is just a (simulated) loop that applies the same
>>> template in sequence. -- Andrei
>>
>> staticMap is a recursive variadic template.
>
> Can recursion be replaced with iteration? Assume you have static foreach at your disposal. -- Andrei

You tell me, you are the expert on templates :o)
I cannot be certain but I think, It would probably work.

static foreach on the other hand is a whole new can of worms.
As walter will be able to tell you.

September 15, 2016
On 09/15/2016 10:08 AM, Stefan Koch wrote:
> static foreach on the other hand is a whole new can of worms.
> As walter will be able to tell you.

It's time to open it. -- Andrei
September 15, 2016
On Thursday, 15 September 2016 at 14:38:41 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 10:08 AM, Stefan Koch wrote:
>> static foreach on the other hand is a whole new can of worms.
>> As walter will be able to tell you.
>
> It's time to open it. -- Andrei

Please give me an example on how it should work.


September 15, 2016
On Thursday, 15 September 2016 at 14:43:16 UTC, Stefan Koch wrote:
> On Thursday, 15 September 2016 at 14:38:41 UTC, Andrei Alexandrescu wrote:
>> On 09/15/2016 10:08 AM, Stefan Koch wrote:
>>> static foreach on the other hand is a whole new can of worms.
>>> As walter will be able to tell you.
>>
>> It's time to open it. -- Andrei
>
> Please give me an example on how it should work.

Are we talking about http://wiki.dlang.org/DIP57 ?

I think I can give you a partial solution for that.
The Performance-Penalty will be less then on templates.

However I can smell a bunch of un-intuitive corner-cases hiding in there.
September 15, 2016
On 9/15/16 6:58 PM, Stefan Koch wrote:
> On Thursday, 15 September 2016 at 14:43:16 UTC, Stefan Koch wrote:
>> On Thursday, 15 September 2016 at 14:38:41 UTC, Andrei Alexandrescu
>> wrote:
>>> On 09/15/2016 10:08 AM, Stefan Koch wrote:
>>>> static foreach on the other hand is a whole new can of worms.
>>>> As walter will be able to tell you.
>>>
>>> It's time to open it. -- Andrei
>>
>> Please give me an example on how it should work.
>
> Are we talking about http://wiki.dlang.org/DIP57 ?
>
> I think I can give you a partial solution for that.
> The Performance-Penalty will be less then on templates.
>
> However I can smell a bunch of un-intuitive corner-cases hiding in there.

Yes, that DIP. It would need some more formal work before defining an implementation. Stefan, would you want to lead that effort? -- Andrei