Just a sample of the Echomail archive
COMPLANC:
[ << oldest | < older | list | newer > | newest >> ]
|  Message 241,192 of 243,097  |
|  David Brown to Janis Papanagnou  |
|  Re: Optimization of cascading recursions  |
|  30 Sep 25 18:04:21  |
 From: david.brown@hesbynett.no On 30/09/2025 17:54, Janis Papanagnou wrote: > In another newsgroup the question came up to what degree the > GNU "C" compilers can handle optimization of recursions like > fib() or ack(), i.e. cascading ones. Somebody here may know? > > Can we expect that (with the higher optimization levels) the > exponential complexity from cascaded recursion gets linearized? > > Janis Optimising compilers can generally handle straight tail recursion well enough. So if you write a simple "fib" function with two recursions, you'll get one turned into a loop and the other kept as recursion. I don't think there is a general way to turn multiple recursions into loops - you have to make a stack-like data structure somewhere along the line, and no C compiler is going to do that automatically. You might find that compilers like the GHC for Haskell can do better, since recursion is the bread and butter of functional programming languages. --- SoupGate-Win32 v1.05 * Origin: you cannot sedate... all the things you hate (1:229/2) |
[ << oldest | < older | list | newer > | newest >> ]
(c) 1994, bbs@darkrealms.ca