[PRL] almost tail-calling (was: Re: deeep stack)

John Clements clements at brinckerhoff.org
Fri May 23 14:13:13 EDT 2008


On May 23, 2008, at 10:59 AM, William D Clinger wrote:

> John Clements wrote:
>> Just now, I decided to see how deep you could go (see *1* below), and
>> I got to
>>
>> 518660
>>
>> That is, Java's not tail-calling, but that's not bad.  Now, these are
>> itty bitty stack frames.  Adding another argument to the procedure
>> pulls this down to 346000, and adding a third brings it down to  
>> 259000.
>
> This is implementation-dependent, of course.
>
> If this is Sun's JVM, then the numbers cited are
> a big improvement over a few years ago, when stack
> overflows would occur after about 10,000 recursive
> calls.

Yes, and of course it's also dependent on system memory; I tried to  
control for this, but discovered that (at least on my OSX 10.4 Java  
1.5) mac, the -Xmx command-line argument had no effect on this number.

Also, you need look no further than Joshua Zucker's post yesterday on  
plt-scheme to see an example where you want a tail-calling loop to go  
deeper than hundreds of millions.

John

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
Url : https://lists.ccs.neu.edu/pipermail/prl/attachments/20080523/7200660e/attachment.bin 


More information about the PRL mailing list