[m-rev.] diff: allow memo tables to be reset
Ralph Becket
rafe at cs.mu.OZ.AU
Mon Mar 7 16:46:55 AEDT 2005
Zoltan Somogyi, Monday, 7 March 2005:
> On 07-Mar-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
> > Would it be a good idea to have a version of memoing where the memo
> > tables only last for the duration of a call?
>
> Yes, it would. However, since such calls may be nested, it is not at all
> obvious how one could implement it without adding distributed fat.
How about converting
:- pragma memo_transient(p/n).
p(...) :- ...
into something like
:- pragma foreign_code("C", "int p_depth = 0;")
:- pragma foreign_proc("C", p_depth = (X::out),
[will_not_call_mercury, promise_pure],
"X = (MR_Word) &p_depth;"
).
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
).
where get_trailed_global, set_trailed_global, and reset_p_table do the
obvious thing.
-- 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