[m-dev.] tabling, trailing and impure references

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Aug 4 14:05:51 AEST 2003


On 04-Aug-2003, David Overton <dmo at cs.mu.OZ.AU> wrote:
> I have a few questions about the implementation of tabling.  We are
> wondering whether it is possible to implement global variables (for HAL)
> using reference.m / nb_reference.m and tabling.
...
> Question 1:	How reliable is this approach?  Does the
> 		`:- pragma memo' guarantee that my_ref will
> 		always return the same reference?

In the current implementation, yes.

In the long term, we might do something a bit more clever with regard
to garbage collection of memo tables.  However, if we do ever do
that, I think we should provide something which keeps the old behaviour,
at least for the zero-arity case.  So I think it would be reasonable
for you to rely on it.  I think at worst you might at some point in
the future have to change the pragma name from "pragma memo" to
something else.

> Question 2:	The reference manual says: "if you enable the use of
> 		trailing ... then any use of tabling will result in a
> 		"Sorry, not implemented" error at runtime."
> 		
> 		I get no such error from the above example in grade
> 		asm_fast.gc.tr.  Does this mean the reference manual is
> 		out of date, or have I just been lucky?

I think the reference manual may be incorrect and/or out of date.

I think that only applies to minimal model (and/or model_non) tabling.

The "sorry, not implemented" error which is referred to in the
documentation was in library/private_builtin.m, in the code
for table_resume/1:

 | #ifdef MR_USE_TRAIL
 |        /*
 |        ** We ought to save the trail state here --
 |        ** this is not yet implemented.
 |        */
 |        fatal_error(""Sorry, not implemented: ""
 |                ""can't have both tabling and trailing"");
 | #endif

But this code was deleted in revision 1.19:
 
 | revision 1.19
 | date: 1999/04/20 11:48:01;  author: zs;  state: Exp;  lines: +841 -1155
 | Estimated hours taken: 130
 | 
 | Rewrite significant parts of minimal model tabling so that it works
 | in a much wider variety of situations, including coups. Also, clean up
 | the tabling implementation to make it more maintainable, and introduce
 | a new grade component, .mm, that enables minimal model tabling.
 | ...

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "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.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list