[plt-scheme] Re: Tail recursion and the Visitor Pattern

From: Dave Herman (dherman at ccs.neu.edu)
Date: Thu Jan 11 00:07:36 EST 2007

>> Try a Visitor that uses an accumulator. Then test it on a large data
>> set and weep. Java isn't TCO [I declare this a new English adjective
>> as of now], meaning it doesn't allow programmers to design according
>> to OO principles. Instead you MUST put yourself into the mind-set of
>> a prehistoric IMPERATIVE programmer and work from there.
> 
> So even if I could figure out how to use an accumulator/replace the
> embedded (indirect recursion) with  tail recursive (not sure how or
> which) , lack of TCO means I would still get a stack overflow, right?

Right. Making a method tail recursive in Java is pointless because (to 
use Matthias's term) Java is not TCO. So tail-recursive Java method 
calls still accumulate stack without bound. And Java only gives you a 
fixed amount of stack space and then blows up with a stack overflow error.

Dave



Posted on the users mailing list.