> > Ning Wang wrote:
 > >> 
 > >> Tailrecursion can be translated into loop right?
 > >
 > > Not in the general case when you tail-call an unknown function (unless
 > > you are thinking of whole program optimisations), e.g. a function
 > > variable.
 > 
 > Is this still true if you use GCC with the option
 > -foptimize-sibling-calls?

Not if gcc is still wedded to the standard calling sequence.
Unless things have change radically since I last checked (always a
possibility with gcc, it is the case that under this option

  1. gcc optimizes a large fraction of tail calls, but not all of them.

  2. Unless you are very familiar with gcc internals, it is very
     difficult to predict which calls get optimized.

If there are gcc developers on the list, I welcome correction on these
points. 

Anyone who is uncertain what I mean by a tail call should consult Will
Clinger's definitive paper at http://tinyurl.com/5rs9lc.  There is
also a good explanation in the Scheme language definition.

It is most unfortunate that Will's paper uses the obsolete term 'tail
recursion'.


Norman
_______________________________________________
Cminusminus mailing list
[email protected]
https://cminusminus.org/mailman/listinfo/cminusminus

Reply via email to