[mercury-users] Re-ordering and getters/setters

Peter Schachte schachte at csse.unimelb.edu.au
Fri Aug 4 11:33:33 AEST 2006

On Thu, Aug 03, 2006 at 08:43:39PM +1000, Jonathan Morgan wrote:
> >set_property(Val0, Obj, !IO),
> >A = Obj ^ property,
> >set_property(Val1, Obj, !IO),
> >B = Obj ^ property,
> >
> >A should equal B here, since they both equal Obj ^ property, but if Val0
> >\= Val1 then this won't be the case
> The other alternative is to use uniqueness and state-vars - but that
> means that everything that may possibly affect the variables must use
> state-var notation, which it seems to me is too high a notational cost
> just to use getters in a more 'natural' way.

Aside from the fact that pred declarations have to show two arguments
where the clauses for it and calls to it show only one, I don't see
how state var notation is any notational cost.  Using that would save
you from having to thread the IO state everywhere.  Or, alternatively,
it saves you from having to pass two arguments to thread the data
through your code.

One little enhancement, discussed recently on this list, would allow
you to write

    !Obj ^ property := Val0,
    A = !.Obj ^ property,
    !Obj ^ property := Val1,
    B = !.Obj ^ property,

Which looks more natural to me than the code you wanted to write

Peter Schachte              I love deadlines. I like the whooshing sound
schachte at cs.mu.OZ.AU        they make as they fly by.
www.cs.mu.oz.au/~schachte/      -- Douglas Adams 
Phone: +61 3 8344 1338      
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list