[m-dev.] for review: cleanup of tabling

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Dec 31 02:40:10 AEDT 1999


On 30-Dec-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > Why not use
> > 
> > 	enum {
> > 	   MR_SIMPLETABLE_UNINITIALIZED,
> > 	   MR_SIMPLETABLE_WORKING,
> > 	   MR_SIMPLETABLE_FAILED,
> > 	   MR_SIMPLETABLE_SUCCEEDED
> > 	};
> > 	typedef Integer MR_SimpletableStatus;
> 
> What does this do that the implemented approach doesn't?

(1) It means that commands such as `print MR_SIMPLETABLE_FAILED'
    or `watch (x == MR_SIMPLETABLE_FAILED)' in gdb will work.

(2) It makes it clear that these constants form an enumeration.

> Remember, the code
> must do a >= comparison on MR_SIMPLETABLE_SUCCEEDED;
> if it were in an enum, that would look odd.

Ah, I see, it's really a discriminated union: either one of those enumeration
constants, or a pointer.
   
Well, in that case, the argument for using an enum is weaker.
I might still use an enum myself, because of (1), but if you prefer to
use #defines that is fine with me.

(BTW, if you're using representation tricks like this, then I think it is
perhaps not a bad thing if the code looks odd ;-)

> >> Memoization and loop check could possibly be made to work for MLDS, after
> >> a lot of work has been put into eliminating the assumptions currently built
> >> in (e.g. all arguments are Word sized) that are not true for the MLDS.
> > 
> > I don't think that assumption is really built in.
> 
> Answer tables are indexed by output argument number; this requires all
> output args to be the same size.

That only requires that they be the same size when stored in the answer table,
not that they be the same size when passed as arguments.

The current code for tabling float arguments should work fine with the MLDS.
It uses the C interface, so the boxing or unboxing needed will be handled
automatically to match the types used by the C interface functions.
Even with your changes in this diff, I think it should still work fine
for the MLDS, so long as you fix the bug (for both LLDS and MLDS backends)
that you introduced in table_save_float_ans/3 -- see the comment on this
in my other mail.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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