Re: Prolog, memory management and memory leaks
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 29 Jan 2008 14:35:10 GMT
On 2008-01-29, A.L <alewando@xxxxxxxxxxxx> wrote:
On 29 Jan 2008 08:15:25 GMT, Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
wrote:
On 2008-01-28, bart demoen <bmd@xxxxxxxxxxxxxx> wrote:
And to agree even more with Jan, I would say: use failure driven
loops; do your cleanup after backtracking.
I don't know where you got that from Bart, but it isn't *my* advice. The
big problem of failure driven loops is they tend to succeed without
having done all the work.
All the work - regarding memory management?..
All the work as in
loop :-
( repeat,
step1,
step2,
step3,
fail
; true
).
and step2 fails while this is not intended. This programs nicely
does step1 and some bit of step2 in a loop but never warns that it
doesn't do the whole thing.
The other problem is that often there some
state to be preserved and it goas into the dynamic database.
If there is no state at all, forall/2 is a good way to do a failure
driven loop though. I.e., this is fine:
forall(repeat, main_goal).
... and if there is no forall?...
forall(Cond, Action) :-
\+ (Cond, \+(Action)).
--- Jan
.
- References:
- Prolog, memory management and memory leaks
- From: A . L .
- Re: Prolog, memory management and memory leaks
- From: bart demoen
- Re: Prolog, memory management and memory leaks
- From: Jan Wielemaker
- Re: Prolog, memory management and memory leaks
- From: A . L .
- Prolog, memory management and memory leaks
- Prev by Date: Re: Prolog, memory management and memory leaks
- Next by Date: Re: Prolog, memory management and memory leaks
- Previous by thread: Re: Prolog, memory management and memory leaks
- Next by thread: Re: Prolog, memory management and memory leaks
- Index(es):