[m-rev.] diff: allow memo tables to be reset

Ralph Becket rafe at cs.mu.OZ.AU
Mon Mar 7 18:01:45 AEDT 2005


Zoltan Somogyi, Monday,  7 March 2005:
> On 07-Mar-2005, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > where get_trailed_global, set_trailed_global, and reset_p_table do the
> > obvious thing.
> 
> I don't know what "obvious thing" you mean. Tabling is mostly used
> in non-trailing grades. Duplicating trailing's functionality in other grades
> would be a big juicy piece of distributed fat. In any case, I don't think
> there is any need for trailing in your example.

You're right, trailing is unnecessary.  But the details of the "p_depth"
machinery in the example aren't that important.

> > 	p(...) :-
> > 		impure X = get_trailed_global(p_depth),
> > 		impure set_trailed_global(p_depth, X + 1),
> > 		...,
> > 		impure set_trailed_global(p_depth, X),
> > 		( if X = 0 then
> > 			impure reset_p_table
> > 		  else
> > 		  	true
> > 		).
> 
> This doesn't work. If p calls q, and some plain memo tabled predicate r
> also calls q, how do we know which entries in q's table we need to reset
> when the top-level call to p exits? 

I hadn't thought of that.  Would having some additional, global flag to
indicate whether it's safe to clear a transient table be a suitable
workaround?  A call to an r-like predicate would set the flag; the flag
would only be cleared once there are no choicepoints to r-like calls
lying around.  Transient tables would only be reset if the global flag
is clear.

Rereading that, it sounds like a very sordid hack...

-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list