🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #2024

Re: Garbage collecting names in Prolog

#2024
From: Richard A. O'Keefe
Date: Fri, 12 Apr 1991 06:52
46 lines
2930 bytes
In article <1991Apr5.143158.7857@swift.cs.tcd.ie>, brady@swift.cs.tcd.ie writes:
> Here is a question about garbage collection.
> However, when it comes to names or functors, what do you implementers do?

I can't speak for any implementors.  I will say, however, that if one of
the less well-considered proposals currently before the ISO committee is
adopted (---- -----, you should know who you are) garbage collecting atoms
will be absolutely indispensible on small machines.

> Do you (a) not bother gc-ing the names store?
> (b) remove all names that are not accessible from the current program?
> (c) something else...

> With (b), it seems that the operation of the standard bip 'current_functor'
> may be affected - it will mean 'a functor that is referred to by the current
> program or process' rather than 'a functor that was once defined'.

DEC-10 Prolog and C Prolog implemented current_functor/2, but many other
Prologs since (including Quintus Prolog) have simply provided a stub that
says "this isn't implemented yet".  I think it has been agreed for a long
time that this EP should not be in the standard.  It is rather hard to say
what it means, and it is _extremely_ expensive to implement in the WAM or
in something like PopLog.  current_atom/1 is not in the standard either.
If we define
    current_atom(X)
	is true when X is a symbol which was reachable from the state of
	the program at the time the call to current_atom/1 started, and
	may be true of additional symbols
then we have something which can be made to work consistently even in the
presence of garbage collection.  (The simplest approach involves using a
global 'clock' for clause time-stamping.)  Making this rigorous may be
more trouble than it is worth.  The big question is "how much can we
promise?".  A definition which promises enough to be useful without
promising too much to be implementable is
    current_atom(X)
	is true only of symbols; the symbols it is true of include the
	symbols which appear in clauses of static predicates, and may
	include others.

Note that in a "distributed" system like the Logix implementation of
FCP, current_atom/1 itself would be extremely difficult to implement,
and it's not clear that any useful meaning could be attached to it.
-- 
It is indeed manifest that dead men are formed from living ones;
but it does not follow from that, that living men are formed from dead ones.
			-- Tertullian, on reincarnation.
Technical Details
Message-ID: <5218@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!munnari.oz.au!goanna!ok
References: <1991Apr5.143158.7857@swift.cs.tcd.ie>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!munnari.oz.au!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: Garbage collecting names in Prolog
Message-ID: <5218@goanna.cs.rmit.oz.au>
Date: 12 Apr 91 06:52:25 GMT
References: <1991Apr5.143158.7857@swift.cs.tcd.ie>
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 46