Tail call optimization?

Stewart Gordon smjg_1998 at yahoo.com
Mon Mar 19 04:16:38 PDT 2012


On 18/03/2012 21:28, bearophile wrote:
> Alex Rønne Petersen Wrote:
>
>> Does D to tail call optimization of any kind?
>
> The D standard doesn't require the D compiler to perform that optimization (unlike Scheme).
> Currently both DMD and LDC are able to perform tail call optimization in some normal
> cases. And I presume GDC is able to do the same.

What are "normal cases"?

- where the function directly tail-calls itself?
- where two functions mutually tail-call each other?
- where a function tail-calls another non-recursively?

And in the last case, I can see that it depends on being able to replace the caller's 
stack frame with the callee's.  But what does this depend on - just the relative sizes of 
the functions' stack frames, or is it more subtle than that?

Stewart.


More information about the Digitalmars-d-learn mailing list