[metapost] Re: all intersections between two paths

Laurence Finston lfinsto1 at gwdg.de
Mon Jan 17 13:25:19 CET 2005

On Mon, 17 Jan 2005, Hans Hagen wrote:

> most cpu's are optimized for that kind of stack handling, as are compilers,

Thanks for the information.

What happens when a function accesses local variables and/or changes the
values of a static variable following a recursive call to the same

> in this case, a few hundred stack frames are neglectable to what
> other threads
> in your OS may be doing; there are also languages that are build around
> recursion (functional languages and such)

Since GNU 3DLDF uses POSIX threads, and the size of the stacks for
threads is generally much smaller than that of the single stack for a
process without POSIX threads, I think that it's important to try
keep the thread stacks from getting too large.  I just tried to check
whether this has changed, and whether thread stacks can be extended
dynamically, but I don't have my threads book (Butenhof)
handy, and I don't know the names of the functions, so I can't find the
man pages.

> in general, in languages like tex/mp, copying data structures take the most
> time, so don't worry about speed-up here; (in tex for instance, fully
> expandable, recursive macros are way faster than loops with counters)

With all due respect, I think this is an area where TeX and MF
use completely different strategies.  If I remember correctly,
Knuth had to be talked into including loops in TeX, and in my
opinion, they're not the nicest part of TeX.  While TeX has
loops and MF has macros, if I had to describe
TeX and MF in no more than two words each, I would say that TeX
is a "macro processor" and MF is an "interpreter".  It therefore
stands to reason that the implementation of macros, including the
handling of recursion, would be especially efficient in TeX, while
that of loops would be especially efficient in MF.  In GNU 3DLDF,
and I suspect in MF, the cost of a macro call is largely the cost
of copying the replacement text, replacing placeholders with the
arguments, arranging to read input from the copy, and arranging to
return to the original input source when it's been read.


More information about the metapost mailing list