Re:Tail Call Improvements in .NET Framework 4
by amock on Tuesday March 09, 2010 @03:05PM
(#1179230)
Yes, but I don't think that's more true of TailCallHelper than of any function calls using a stack. This sounds like it's saying that even with tail call optimization it's possible for the arguments to a function to be too big for the stack. For example, if the arguments you pass to the recursive function call are stack allocated and grow each time then each call will increase stack usage, even though it's reusing the space from the previous call.
Re:Tail Call Improvements in .NET Framework 4
by mquander on Tuesday March 09, 2010 @03:24PM
(#1179263)
It sounds to me like the stack space required by TailCallHelper is proportional to the largest amount of stack space ever consumed by a single call of the tail recursive function(s) it's assisting, whereas without it, the stack space required would be proportional to the depth of recursive nesting. So using TailCallHelper you should be able to guarantee arbitrarily deep tail recursion.
Re:Tail Call Improvements in .NET Framework 4
by bad_user on Tuesday March 09, 2010 @04:35PM
(#1179454)
It seems to me that the TailCallHelper is just a trampoline ... the method wanting to do a tail call places on the stack a reference to the next method to be called + it's arguments, returns, and then TailCallHelper calls it.
So yeah ... you have a guarantee, but it's also using stack space, so you have to watch-out for big arguments lists, because that may overflow the stack.
- does this mean that it's possible to use TailCallHelper but still not be able to guarantee no stack overflow?