[m-dev.] Trailing

Peter Schachte pets at students.cs.mu.oz.au
Mon Aug 11 16:07:17 AEST 1997


Before I start, I should point out that I referred in my proposal to the
wrong choicepoint register.  Wherever I refer to cur_fr it should be max_fr.

On Sat, 9 Aug 1997, Fergus Henderson wrote:

> > So this suggests the following interface:
> > 
> > 	void  MR_trail_value(Word *address, Word value);
> > 		Make sure that when the current execution is
> > 		backtracked over, value is placed in address.
> > 	
> > 	enum {undo,commit} untrail_reason;
> 
> s/undo/MR_undo/
> s/commit/MR_commit/
> s/untrail_reason/MR_untrail_reason/
> 
> Also you should add `MR_exception' to this enum now rather than later.

Fair enough.  Does this mean you think it likely that exception handling
will ultimately become part of the Mercury language and/or the Melbourne
implementation?

> > 	void *MR_cut_to_choicepoint(Word cp);
> > 		Assigns cur_fr = cp, but first traverses the function
> > 		trail calling (*reset)(value,commit) for each entry.
>
> Would it be better to make that
>  	void *MR_cut_to_choicepoint(Word cp, untrail_reason reason);
>  		Assigns cur_fr = cp, but first traverses the function
>  		trail calling (*reset)(value,reason) for each entry.

If we're adding MR_exception now, then yes.

> > I know there are probably not many (any?) predicates in the current
> > Mercury system or library that can commit to a choice, but they can be
> > written using the C interface.  It is debatable whether or not the
> > complication necessary to support this facility is worthwhile.
> 
> What complication is necessary?

The complication of having the the untrail reason argument to the untrail
functions.  They won't often be needed, and having the argument there means
it will have to be checked (because you almost never want to do the same
thing when you fail as you do when a choicepoint is trimmmed or an exception
happens) on each un(function)trail operation.

An alternative interface would be to pass the untrail reason when pushing
the trail function entry, the entry only being called when it is untrailed
for that reason.  If it can be implemented efficiently enough, this would
probably be preferable. 


-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