users-prolog
[Top][All Lists]
Advanced

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

Re: Iteratively calling Prolog from C


From: Fergus Henderson
Subject: Re: Iteratively calling Prolog from C
Date: Fri, 18 Jul 2003 15:36:26 +1000
User-agent: Mutt/1.3.28i

On 17-Jul-2003, Bartek Wilczynski <address@hidden> wrote:
> 
> The problem of recursion optimization is usually caused not by the time
> overhead, but by the memory usage on the stack. 18000 recursive calls is not
> much. The problem begins when you try to somehow create a list of let's say
> 100.000.000 atoms using a recursive call. The list itself doesn't take you too
> much memory, but the stack is overfilled with the recursive calls. 
> 
> Tail recursion optimization tries to help you with it, but unfortunately it's
> not implemented well in gprolog (to my best knowledge).

What makes you think that?  I'm pretty sure that there is no problem
with tail recursion optimization in GNU Prolog.  The GNU Prolog
implementation is based on the WAM, and there is absolutely no problem
with tail recursion optimization in the WAM.

There may be problems related to garbage collection or lack thereof,
but that is really a quite separate issue.

For some suggestions on how to work around problems with Prolog systems
that lack support for garbage collection, see Richard O'Keefe's book
"The Craft of Prolog".  However, good Prolog implementations do support
garbage collection, so if your Prolog implementation does not, then I
suggest you switch to one that does.

-- 
Fergus Henderson <address@hidden>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.




reply via email to

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