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

Peter Schachte schachte at csse.unimelb.edu.au
Thu Nov 9 15:34:37 AEDT 2006


On Thu, Nov 09, 2006 at 01:36:39PM +1100, Julien Fischer wrote:
> The problem is that if q(X) is inlined we get:
> 
> 	p(X) :-
> 		trace(...),
> 		r(X),
> 		s(X).
> 
> If r(X) is then determined to be unecessary we are then left with:
> 
> 	p(X) :-
> 		trace(...),
> 		s(X).

This might work better if trace goals were "wrapped around" the
declarative code they refer to.  Something like

	trace Params Before Declarative After

would be equivalent to what would currently be written

	trace Params Before,
	Declarative,
	trace Params After

except that if Declarative is optimised away, then the trace goals are
removed, too.

This might be too much of a pain to implement, though, because trace/4
couldn't just be a higher order predicate, it would have to be
explicitly handled by all passes over the HLDS.


On Thu, Nov 09, 2006 at 02:50:21PM +1100, Mark Brown wrote:
> Yes.  My point was that unnecessary code removal must be done before
> inlining in order to match the spec.

But this is suboptimal because inlining may create new opportunities
for code removal.


On Thu, Nov 09, 2006 at 02:37:44PM +1100, Mark Brown wrote:
> An alternative (and
> better) way of helping users debug this problem would be to give a warning
> whenever a promised pure goal is optimised away.

What's dubious about optimising a promised pure goal away?  Would you
also warn about optimising away a pure goal that does nothing but call
a promised pure predicate?  The trouble with warnings like this is
that you need a way to turn them off, a new declaration that says
"yes, this goal is pure, I really, really promise, cross my heart.
Now please don't warn me about this."

-- 
Peter Schachte              There never has been, nor will there ever be,
schachte at cs.mu.OZ.AU        any programming language in which it is the
www.cs.mu.oz.au/~schachte/  least bit difficult to write bad code.
Phone: +61 3 8344 1338          -- Lawrence Flon 
--------------------------------------------------------------------------
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