help-3dldf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-3dldf] Re: all intersections between two paths


From: Hans Hagen
Subject: [help-3dldf] Re: all intersections between two paths
Date: Mon, 17 Jan 2005 12:04:53 +0100
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

Laurence Finston wrote:

I don't think there's anything _wrong_ with it.  As I understand it,
where tail recursion is possible, there is indeed no problem.
Roughly speaking, and again as I understand it,
in C and C++, the price of a function call
is a stack frame, whereas the price of a loop is a handful of machine
instructions.

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

The price of an additional, recursive call to a function is another stack
frame, whereas the price of an additional iteration is testing a
conditional and a jump, i.e., negligible.

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)

I don't know whether optimizing compilers (or perhaps the run-time system?)
can recognize where tail recursion is possible and eliminate
stack frame nesting;  nor do I know how a programmer could tell the
compiler to do this, where possible, nor whether it would be wise for a
programmer to depend on this behavior.  If you or anyone else knows
about this subject, I'd be very interested in learning more.

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)

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]