static map as a type function

Stefan Koch uplink.coder at
Thu Sep 24 15:43:39 UTC 2020

On Thursday, 24 September 2020 at 15:34:06 UTC, H. S. Teoh wrote:

> what I had in mind was what Walter said about leveraging the 
> existing language instead of adding new features.  My thought 
> was to introduce new syntax that maps to the current template 
> implementation (recursion, etc.):

That means changing the langauge.

> new syntax won't significantly add to the weight of the 
> language since you're not defining new semantics.  This solves 
> the writability / readability problem.

It's debatable of that won't add to the weight of the language.

>  Then the next step is to improve the implementation, so that 
> it benefits both existing template code and, by extension, the 
> new syntax. This would solve the performance issue, or at least 
> address it.

Sure, if there is any theoretically sound way to extract a 
monomorphic iterative form out of a polymorphic recursion in O(1).
And when you have found it you _just_ have to implement it, 

> Or maybe a more sensible approach is to implement a template 
> optimizer with the current language, that optimizes certain 
> patterns into iterative code, then at a later point introduce 
> primitives that let you access this iterative code directly.

So you are saying first introduce type functions to be used under 
the hood an later on make them available?

More information about the Digitalmars-d mailing list