[m-dev.] updated trail handling

Peter Schachte pets at students.cs.mu.oz.au
Thu Aug 14 15:10:56 AEST 1997


On Thu, 14 Aug 1997, Fergus Henderson wrote:

Hi Fergus,

One suggestion.

> Index: mercury_trail.h

...

> +	/* restore the solver to the state given in the ticket starting at x */
> +#define restore_and_discard_ticket(old)				\
> +	do {							\
> +		MR_TrailEntry *old_trail_ptr =  		\
> +			(MR_TrailEntry *)old;			\
> +		if (MR_trail_ptr != old_trail_ptr) {		\
> +			save_transient_registers();		\
> +			MR_untrail_to(old_trail_ptr, MR_undo);	\
> +			restore_transient_registers();		\
> +		}						\
> +		--MR_ticket_counter;				\
> +	} while(0)
> +
> +	/* 
> +	** discard the top ticket
> +	*/
> +#define discard_ticket(old_trail_ptr) 			\
> +	do {						\
> +		save_transient_registers();		\
> +		MR_untrail_to((MR_TrailEntry *) old_trail_ptr, MR_commit); \
> +		restore_transient_registers();		\
> +		--MR_ticket_counter;			\
> +	} while(0);

The discard_ticket() macro should probably be more like
restore_and_discard_ticket(), with the same if test avoiding the untrailing
when there's nothing on the trail.  Better still, for maintainability, make
a new macro abstracting the two, with the MR_untrail_reason as an extra
parameter, and define both discard_ticket() and restore_and_discard_ticket()
in terms of that.


-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