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

Laurence Finston lfinsto1 at gwdg.de
Wed Jan 19 22:59:57 CET 2005

Larry Siebenmann wrote:

>  > 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.
> Excellent suggestion; I am still mulling it over.

Thanks.  One does one's best.

> Indeed! How can one expect geometers to adopt MP, as an
> intimate professional tool if their favorite mode of
> reasoning is hobbled?

Do you think this is a reasonable expectation?  I think TeX, MF, and MP
perform a limited range of functions very well.  I apply something I call "the
three `\expandafters' rule":  If anything needs more than three
`\expandafters', I write a preprocessor instead.  This is a bit of an
exaggeration, especially since TeX is very interesting viewed simply as a
macro processor, apart from its typesetting functionality, but you get the
idea.  I've found that it works very well to write programs that write TeX
code, TeX macros that write LISP code, C programs that preprocess TeX code,

Put in a somewhat oversimplified way, I think MF was designed to draw curves
and it does that very well.  I wish the curves it drew were projectively
invariant, but Knuth was apparently not thinking about the third dimension. 
So it gives me something to do.  MF wasn't designed to express recurrence
relations, if that's what you mean (and the correct term).  I think it could
be a powerful tool for a geometer, but one would have to learn what it does
well and what it doesn't.

> It seems to
> me that the use of a home-made stack (housed in an array
> for lack of alternatives?) might be a slightly better
> solution. 

> QUESTIONS. What is the RAM cost of an 'array' element of
> type pair?  Is there some way of recycling useless
> array elements -- maybe similar to TeX's \let
> \macroxxx=\undefined? Is there a good example of 
> the use of a stack in MF/MP programming.

This is just my opinion, but if you're thinking this way, I'm not sure working
within MP is the best way to go about solving the problem.  Instead, you could
write a program to do the calculations and have it write MP code as its
output.  Then you wouldn't be so restricted by MP's limitations.  You could
implement tail recursion, implement high-precision arithmetic, do garbage
collection, and whatever else you want.


More information about the metapost mailing list