Find limit of recursion: Difference between revisions

m
(→‎{{header|ALGOL 68}}: Not so silly a task. Think outside Algol68 or just reserve your judgement for the comment page and state as an opinion.)
Line 56:
The depth of recursion in Algol 68 proper is unlimited. Particular implementations will reach a limit, if only through exhaustion of storage and/or address space and/or time before power failure. If not time limited, the depth reached depends very much on what the recursive routine needs to store on the stack, including local variables if any. The simplest recursive Algol68 program is:
<lang algol68>PROC recurse = VOID : recurse; recurse</lang>
For what it's worth thisThis one-liner running under Algol68 Genie and 64-bit Linux reaches a depth of 3535 with the shell's default stack size of 8Mbytes and 28672 when set to 64Mbytes,
as shown by the following output. From this we can deduce that Genie does not implement tail recursion. The --trace option to a68g prints a stack trace when the program crashes; the first two commands indicate the format of the trace, the third counts the depth of recursion with the default stack size and the fourth shows the result of octupling the size of the stack.
{{Out}}
Anonymous user