You will find that the exit will purely return you to the last recursive

call you made, take the following example...

Function Factorial(Number: Integer): Integer;

begin

if Number=1 Then

Factorial:=1

else

Factorial:=Number * Factorial(Number-1);

end;

If you changed it to:

Function Factorial(Number: Integer): Integer;

begin

if Number=1 Then

begin

Factorial:=1;

exit;

end

else

Factorial:=Number * Factorial(Number-1);

end;

it should behave exactly the same...

Quote:

> Hello fellow darksiders.

> Here's a weird one for you. I am actually using THINK Pascal for the

> Mac, but the question is quite general. Suppose that I declare a

> recursive proc that has the standard if else structure (If condition

> dosomething else call again(with new data). What happens if at some

> level of nesting I call Exit(proc)??????? Will ALL the stack frames get

> deallocated (in my Mac its LINK/UNLK) or just the last one? I guess what

> I am asking is WHERE the proc will exit? Just before the last call or

> just after the first call? Couldn't figure this one out, although I

> suspect that the Exit statement deallocates the whole thing.

> Any thoughts are welcome. Thanx in advance.

--

Daniel Silverstone (Usually ;)

Look at the farstar Homepages on:

http://www.farstar.demon.co.uk/

Try out Daniel's TPascal Page & Delphi 2.0 bits at

http://www.farstar.demon.co.uk/Pascal/index.htm

Mail me & give comments (I know it's sparse ;)