[m-dev.] changes to the CLP(R) interface stuff

Peter Schachte pets at students.cs.mu.oz.au
Mon Aug 25 11:35:03 AEST 1997


On Sun, 24 Aug 1997, Fergus Henderson wrote:

> clpr/mercury_solver.h:
> 	Removed.  The stuff that was in here has migrated;
> 	some of it is in clpr/clpr_misc.h, and some is in
> 	svar.m.
> 
> svar.m:
> 	Various changes to make it use the new trailing interface.
> 	(It still doesn't quite work, though.)
> 
> The first 200 lines of this diff are intersting; after that,
> it is all boiler-plate stuff.  Peter, can you please review this?

This looks good.

I'm a bit suspicious of the double-linking of ML_svar_trail_entry structs,
though.  Firstly, isn't malloc() supposed to be efficient enough these days
to make all this unnecessary?  Secondly, if not, then we ought to be able to
get by with just the next pointer.  In ML_svar_untrail_func, instead of
calling ML_svar_prev_trail_entry(), we can just set ML_svar_trail_ptr to the
supplied ML_svar_trail_entry.  This should work because ML_svar_untrail_func
should get called once for each trail entry before it is called for any
previously-created trail entries.

Also, shouldn't the MR_commit case below clean up the solver's own trail?
I'd have expected cut in CLP(R) to do some trail cleanup, and I'd have
expected MR_commit to be able to do the same cleanup.

> +void ML_svar_untrail_func(Word datum, MR_untrail_reason reason) {
> +	ML_svar_trail_entry *trail_entry = (ML_svar_trail_entry *) datum;
> +	switch (reason) {
> +		case MR_undo:
> +		case MR_exception:
> +		{
> +			int old_trtop, i;
> +
> +			stamp = trail_entry->stamp;
> +			slack_id = trail_entry->slack_id;
> +			solver_id = trail_entry->solver_id;
> +			old_trtop = trail_entry->trtop;
> +			for (i = trtop - 1; i >= old_trtop; i--) {
> +				solver_backtrack((Word) trail[i]);
> +			}
> +			trtop = old_trtop;
> +			break;
> +		}
> +		case MR_gc:
> +		case MR_commit:
> +		default:
> +			/* do nothing */ ;
> +	}
> +	ML_svar_prev_trail_entry();
> +}

-Peter Schachte      URL:  http://www.cs.mu.oz.au/~pets/
pets at cs.mu.OZ.AU     PGP:  finger pets at 128.250.37.150 for key
    Do insects spend hours demammaling their programs?




More information about the developers mailing list