static map as a type function
newshound2 at digitalmars.com
Thu Sep 24 00:44:21 UTC 2020
On 9/23/2020 4:59 PM, Bruce Carneal wrote:
> On Wednesday, 23 September 2020 at 22:36:55 UTC, Walter Bright wrote:
>> 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.
> I see a few reasons to prefer type functions, wherever applicable (they cant do
> 1) type functions admit a simpler/bounded compiler implementation
> 2) type functions admit simpler meta programs and the related
> 3) type functions should be easier to debug, eager rather than lazy/latent
> compile time errors for one thing
> 4) type functions exhibit better locality than templates
> 5) to achieve type function like simplicity/debuggability with templates you
> need to rely more heavily on "best practices"
I don't really understand these points.
Using the existing recursive template calls is well-known and well-understood
functional style programming. It even aesthetically looks and acts like function
calls, except with a bang (!).
Making existing constructs work better is better than adding an ever-expanding
list of new constructs.
More information about the Digitalmars-d