static map as a type function

Stefan Koch uplink.coder at googlemail.com
Thu Sep 24 03:48:23 UTC 2020


On Wednesday, 23 September 2020 at 22:36:55 UTC, Walter Bright 
wrote:
> On 9/23/2020 4:49 AM, Per Nordlöw wrote:
>> Great work. Has Andrei given any advice on how to proceed 
>> regarding dip, reviews and acceptance? I presume this will get 
>> merged behind a -preview if it gets merged.
>
> The other way to do it is just have the compiler recognize 
> recursive templates and implement them directly. This would 
> provide the speedup, while not adding new features or requiring 
> any user code changes - it'll just run faster.

The problem here is just.
As you might be aware, I have been looking into this problem for 
a while.

The issue is that templates are polymorphic, which means that 
static analysis of a template is not possible, in the general 
case.

The case which I have identified where analysis of a template is 
possible is this one:

- template does not use string mixin dependent on a parameter or 
outer template context.
- template does not use static if's dependent on parameters or 
outer template context.
- template does not use static foreach or foreach dependent on 
parameters or outer template context.

that means no static if, no foreach, and no mixin.
If you can write useful metaprogramming  templates given those 
constraints then it's possible to optimize them.


More information about the Digitalmars-d mailing list