Discussions related to Visual Prolog
hyphz
Posts: 10
Joined: 15 Jan 2013 1:13

Is recursion unwound?

Unread post 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?
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post 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.
Regards Thomas Linder Puls
PDC
Post Reply