Jump to content

Find limit of recursion: Difference between revisions

Add PL/I - limit on z/OS is pretty deep compared to others :)
(Add PL/I - limit on z/OS is pretty deep compared to others :))
Line 591:
Stack overflow
?</pre>
 
=={{header|PL/I}}==
<lang PL/I>
recurs: proc options (main) reorder;
dcl sysprint file;
dcl mod builtin;
 
dcl ri fixed bin(31) init (0);
 
recursive: proc recursive;
ri += 1;
if mod(ri, 1024) = 1 then
put data(ri);
 
call recursive();
end recursive;
end recurs;
</lang>
 
Result (abbreviated):
 
...
RI= 4894721;
RI= 4895745;
RI= 4896769;
RI= 4897793;
RI= '''4898817''';
 
At this stage the program, running on z/OS with a '''REGION=0M''' on the EXEC statement (i.e. grab as much storage as you like), ABENDs with a '''USER COMPLETION CODE=4088 REASON CODE=000003EC'''
 
Obviously, if the procedure '''recursive''' would have contained local variables, the depth of recursion would be reached much earlier...
 
=={{header|PowerShell}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.