static map as a type function
snarwin at gmail.com
Thu Sep 24 13:04:43 UTC 2020
On Thursday, 24 September 2020 at 12:39:57 UTC, Steven
> BTW, I don't see how tail-recursion can be done still. Even
> with your tail-recursive version, you still have to rebuild
> each instance of the template, because you don't know if it's
> going to generate different code via static if. Whereas runtime
> tail recursion builds one version of the function, and just
> jumps back into the same function with modified input.
You have to build N versions, but (in principle) you don't have
to keep them all around in memory--only the last one is
necessary. So you still save on resources compared to naive
template recursion, although not as much as you would with type
> It also helps that the "simple naive" version of the
> typefunction code is the best version. You don't have to write
> it in a special way to make the compiler perform well.
Definitely a valid point. Regardless of one's aesthetic
preferences, recursive templates are not a "pit of success."
More information about the Digitalmars-d