Page 1 of 1

Is recursion unwound?

Posted: 3 Sep 2014 0:40
by hyphz
Hi,

Does the VP7 compiler unwind recursion internally or convert it to branches? For example, if I have the following code:

Code: Select all

pester() :-   write("Say uncle: "),   I = readLine(),   if I <> "uncle" then pester end if.
Is the recursion converted to a branch or could this code potentially trigger a stack overflow if enough "wrong" inputs were entered?

Posted: 3 Sep 2014 6:08
by Thomas Linder Puls
That code will not cause stack overflow.

You can read more about the run stack and last call optimization here: Memory Management.