Stack overflow in good7.fun

0 views
Skip to first unread message

Adam Luotonen

unread,
Mar 6, 2010, 7:00:32 AM3/6/10
to proglang-course-2010
Hi!

I'm implementing lab 4 in Java, and all the good programs work when I
use call by value or call by name except good7.fun. Both my
implementations get a stack overflow there. However if I reduce the
parameter to odd in main, both of them work. Is this a reason to be
rejected? I have optimized away any unnecessary function calls and
stack allocations, and I'm starting to run out of options. One
possibility is to eliminate the recursion in java by using iteration
and a manual stack...

Cheers!

/Adam

Jorge Diz Pico

unread,
Mar 9, 2010, 8:26:16 PM3/9/10
to proglang-c...@googlegroups.com
I'm getting a Stack Overflow as well. I hope it's not a problem...

Krasimir Angelov

unread,
Mar 10, 2010, 1:38:31 AM3/10/10
to proglang-c...@googlegroups.com
I think that everyone who works in Java will get Stack Overflow unless
if you can find some sophisticated work around. This is one of the
well known, in the functional programming community, disadvantages of
JVM. The virtual machine doesn't have instruction for tall calls. For
more information read here:

http://en.wikipedia.org/wiki/Tail_call

There is a solution but it is more like a hack. The .NET virtual
machine for example has proper instruction for doing tail calls and
this in not a problem. It also not a problem with Haskell or any other
functional language.

If everything else works in your interpreter then send it as it is.


Krasimir

Reply all
Reply to author
Forward
0 new messages