[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: garbage collection
From: |
Fergus Henderson |
Subject: |
Re: garbage collection |
Date: |
Wed, 18 Feb 2004 11:13:26 +1100 |
User-agent: |
Mutt/1.4i |
On 17-Feb-2004, Mike Maxwell <address@hidden> wrote:
> Gregory Bourassa wrote:
> > Prolog is generally stack-oriented, so a garbage collecter
> > usually makes sense only for the global heap area, if any.
>
> Thanks for the comments--I looked up "heap" in the index of The Craft of
> Prolog. There are two references, one of which (p 148) doesn't seem to
> pertain, and for the other of which (p 74) I can't seem to find the word on
> the page. Must need new reading glasses... So I'm unclear under what
> circumstances you use the heap, although I gather it's used for compound
> terms.
Right. In Prolog, the "heap" is also known as the "global stack".
> As for I/O, I'll actually be ripping out the original and replacing it with
> my own code. As it happens, the input to the parser comes tokenized, with
> one word per line. So I'm thinking of something like the following (not
> tested yet):
>
> run :-
> repeat,
> readline(Wordform),
> process(Wordform),
> fail.
>
> process(eof) :-
> halt.
> process(Wordform) :-
> parse(Wordform, Parses),
> display(Parses).
>
> If I'm understanding you correctly, it looks like it will backtrack past the
> readline every time it finishes a word, so the heap should be reclaimed at
> that point, correct?
Yes.
--
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.