6.3.2 Quit Recursion

We now illustrate how to quit a recusive call by throwing and catching an exception. The example is a simple recursion that increments a counter but quits the recursion once it gets equal to 10000.

<quit recursion>=
declare proc{Process N}
           if N==10000
           then raise 'error in Process' end 
           else {Process N+1}
           end  
        end 
try 
   {Process 0}
catch Exception then 
   {Browse Exception}
end


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)