[metapost] Re: [metafont] Re: recursion in MP/MF

Laurence Finston lfinsto1 at gwdg.de
Wed Jan 19 23:28:53 CET 2005


>  > However, I think it would be worthwhile to consider whether you
>  > couldn't just put the subpaths onto an array and loop 
>  > over the array until some condition is met.
> 

I looked up "tail recursion" in the indices of several of my computer books. 
It only occurs once in the _TeXbook_ and not at all in the _MFbook_.  It does
not occur in the index to any of the volumes of Knuth's _The Art of Computer
Programming_  although it might be mentioned in one of the many places where
"recursion" is discussed.  
Nor is it mentioned in _Concrete Mathematics_ (Graham, Knuth, and Patashnik). 
I'm pretty sure it's not mentioned in my other books.
The impression I get is that "the compiler is supposed to take care of it".  

Uwe Schoening, in his book _Algorithmik_, says that recursion can always be
replaced by a WHILE loop and a stack.  I wrote down the reference, but forgot
to take it with me.  I believe it is p. 19 and the date of publication was
2001.  The publisher is Spektrum Akademischer Verlag.  
He likes recursion, too, though, for much the same reasons advanced by Taco
and Jacko.  He points out that accessing the function arguments after the
recursive call would make tail recursion impossible, but doesn't say anything
about static variables.

Laurence 
 



More information about the metapost mailing list