Subject: garbage-collecting foreign object refs with lemmas

From: Paul Singleton <[email-masked]>
Date: Sat, 05 Feb 2000 02:30:29 +0000

(Using the new PL_agc_hook, I can represent references to foreign
objects by atoms, then clean them up as appropriate when these atoms
are garbage collected and my cleanup routine is notified)

I want, however, to maintain lemmas about these foreign objects,
indexed by their atoms, without thereby ensuring that they are never
recovered because the atom is still around, if you see what I mean.

Is it feasible to, effectively:

 assert( java_object_type('J#0152375280',class([java,util],['Date'])))

 PL_unregister_atom('J#0152375280')

to fudge the atom reference count so that the occurrence of the atom
in the asserted fact is disregarded for GC purposes?

Is this safe, or can it be otherwise done safely?

When my agc_hook callback is called back, I want to retract all such
facts involving the atom in question.

NB I'm tempted to

  assert( +Fact, -Reference)

then associate the Reference with the magic atom in some foreign table,
and eventually PL_erase(+Record) it:

 * is it the same Reference/Record in Prolog and foreign code?

 * will this be usefully quicker than calling back into Prolog
   to do e.g. a retract?

If this isn't feasible, I may represent foreign objects by a structure
which contains both a magic atom and a corresponding integer, and use
the integer to retrieve cached info about the object, but this is a bit
clumsier...

Paul Singleton