[m-rev.] diff: reset contains_trace_goal if necessary

Peter Schachte schachte at csse.unimelb.edu.au
Fri Nov 10 13:05:27 AEDT 2006


On Fri, Nov 10, 2006 at 12:40:32PM +1100, Mark Brown wrote:
> On 10-Nov-2006, Ian MacLarty <maclarty at csse.unimelb.edu.au> wrote:
> > Actually no it doesn't.  Trace goals are completely outside of the
> > declarative semantics of the program, so they have no effect on purity 
> > whatsoever.
> 
> There's nothing else to stop trace goals from always being optimised away.

That's why I suggested tying them to declarative goals:  so the trace
goals are always executed immediately before and/or after the
declarative goal, and are removed from the code iff the declarative
goal is.

> First, inline q/1 in p/1, making the implicit promise explicit:
> 
> 	p(X) :-
> 		promise_pure (
> 			trace ...,
> 			r(X)
> 		),
> 		s(X).
> 
> Then remove unnecessary code:
> 
> 	p(X) :-
> 		s(X).


But this doesn't help the case where you've got:

	p(...) :-
		trace( ... about to do q ... ),
		q(...),
		trace( ... finished with q ... ),
		trace( ... about to do r ... ),
		r(...),
		trace( ... finished with r ... ).

and you need to reorder q and r.  If you consider the trace goals to
be impure without affecting the purity of p, then you can't reorder q
and r, and compilation fails.  If OTOH you consider the trace goals to
be pure but special in that they can't be optimized away despite being
det and having no outputs, then the trace goals will happen at the
wrong times.

If you instead had

	p(...) :-
		trace([...],
		      ( ... about to do q ... ),
		      q(...),
		      ( ... finished with q ... )),
		trace([...],
		      ( ... about to do r ... ),
		      r(...),
		      ( ... finished with r ... )).

then the trace goals would be reordered or eliminated with the pure
goals.

-- 
Peter Schachte              In order to become the master, the politician
schachte at cs.mu.OZ.AU        poses as the servant.
www.cs.mu.oz.au/~schachte/      -- Charles de Gaulle 
Phone: +61 3 8344 1338      
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list