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

Ian MacLarty maclarty at csse.unimelb.edu.au
Fri Nov 10 09:17:01 AEDT 2006


On Thu, Nov 09, 2006 at 05:22:15PM +1100, Ian MacLarty wrote:
> On Thu, Nov 09, 2006 at 04:34:16PM +1100, Mark Brown wrote:
> > On 09-Nov-2006, Ian MacLarty <maclarty at csse.unimelb.edu.au> wrote:
> > > On Thu, Nov 09, 2006 at 03:02:07PM +1100, Mark Brown wrote:
> > > > On 06-Nov-2006, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> > > > > @@ -2657,6 +2670,84 @@
> > > > >  
> > > > >  %-----------------------------------------------------------------------------%
> > > > >  
> > > > > +:- pred goal_contains_trace(hlds_goal::in, hlds_goal::out,
> > > > > +    contains_trace_goal::out) is det.
> > > > > +
> > > > > +goal_contains_trace(GoalExpr0 - GoalInfo0, GoalExpr - GoalInfo,
> > > > > +        ContainsTrace) :-
> > > > > +    (
> > > > 
> > > > 	...
> > > > 
> > > > > +    ;
> > > > > +        GoalExpr0 = scope(Reason, SubGoal0),
> > > > > +        goal_contains_trace(SubGoal0, SubGoal, ContainsTrace),
> > > > > +        GoalExpr = scope(Reason, SubGoal)
> > > > 
> > > > It appears that this goal feature propagates outside promise_pure scopes.
> > > > I realise this behaviour follows what is in the reference manual, but is
> > > > this really what we want?
> > > > 
> > > > I think that a goal which is explicitly promised pure should be able to
> > > > be optimised away even if it contains trace goals, in the same way that
> > > > a pure call can be optimised away even if there are trace goals in its
> > > > definition.
> > > > 
> > > > Any comments?
> > > > 
> > > 
> > > I agree, but I don't see what the difference between this and what I said
> > > earlier is.
> > 
> > I'm only talking about optimising away goals that are explicitly promised
> > pure (and are det with no outputs, my pedantic friends).
> > 
> > For example, the goal
> > 
> > 	( Cond ->
> > 		trace ...
> > 	;
> > 		trace ...
> > 	)
> > 
> > should not be replaced with "true" unless both trace goals are compiled
> > away.
> > 
> > In effect, trace goals introduce a kind of impurity which is eliminated
> > by promise_pure (as with other kinds of impurity), but which is also
> > implicitly eliminated at the boundary of each clause.  I believe this
> > was Zoltan's intent.
> > 
> 
> That sounds reasonable to me.
> 

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.

I think the current behaviour is fine, except for the issue Pete raised.

I like your idea of warning about pure code that is optimised away.

Ian.
--------------------------------------------------------------------------
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