[m-dev.] Resources example

Peter Schachte schachte at cs.mu.OZ.AU
Thu Apr 28 13:36:47 AEST 2005


On Thu, Apr 28, 2005 at 01:16:08PM +1000, Ralph Becket wrote:
> > True, just as a goal X = [] silently updates the heap.
> 
> Not in any observable way.

Not observable at the user level, but definitely observable to the
implementors of the type (the Mercury compiler crew, in this case).
The same is true of solver predicates changes to the constraint store
resource.

> > > Under these circumstances the compiler can't do things like optimize
> > > away duplicate calls to `contains_duplicate' *anywhere* that it can't
> > > prove that the unification predicate for whatever T doesn't use some
> > > resource.
> > 
> > Nope, because you've promised that unification (and all other
> > constraint predicates) only modify the constraint store in a
> > commutative and idempotent way.  If you haven't made that promise,
> > then you have to precede your calls to those predicates with ! to
> > specify that they may use and/or modify a resource in a possibly
> > non-commutative, non-idempotent way.  Goals with the ! at the front
> > cannot have those optimizations made, any more than goals that use
> > state variables or goals in DCGs can.
> 
> I that case I can't allow my definition of unification to use resources,

Sure you can.  If you implement it correctly, the changes to the
constraint store made by a unification goal will be idempotent and
commutative, so you can declare them so.

> so I need solver types again!

You just need 'where equality is ...' in the type declaration.

-- 
Peter Schachte              The government of the United States is not, in any
schachte at cs.mu.OZ.AU        sense, founded on the Christian religion.
www.cs.mu.oz.au/~schachte/      -- George Washington, 1796 
Phone: +61 3 8344 1338      
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list