Felad=F3: David Matthews [mailto:David.Matthews@prolingua.co.uk]
The general point is that it's possible to avoid recursion by keeping the information elsewhere, in this case in the list. Generally, though, it's going to be faster to use the stack rather than build a list.
On Wed, 17 Oct 2007, Andr=E1s P=E1hi wrote:
Agreed with your final conclusion, that it is generally faster. But stack space is limited compared to the amount of memory available, so there is a trade-off: use the stack for storage for speed, and limit yourself to the stack depth or use the storage memory with slower execution speed, but do not get caught by the stack space limit.
As I understand it, the memory model of the current CVS branch of Poly/ML =
gives you as much stack as heap, depending only on the size of virtual =
memory. In the presence of multi-threading, performance of stack should =
become even better compared to heap, because GC on the latter forces =
single-threaded execution.
Makarius