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

Jonathan Morgan jonmmorgan at gmail.com
Fri Aug 4 11:47:45 AEST 2006

On 04/08/06, Ian MacLarty <maclarty at csse.unimelb.edu.au> wrote:
> On Thu, Aug 03, 2006 at 08:43:39PM +1000, Jonathan Morgan wrote:
> > On 8/3/06, Ian MacLarty <maclarty at csse.unimelb.edu.au> wrote:
> > >Think of your Obj as a key and the IO state as a map, you can't lookup
> > >the value associated with the key without the map.
> > >
> > >To remidy the situation you can either add the IO state arguments to the
> > >getter, make the getter impure, or make the setter impure and the getter
> > >semipure.
> >
> > 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.
> >
> It depends what you mean by 'natural'.  This may seem natural to an
> imperative OO programmer, but it isn't natural in the context of
> declarative programming.

For a start, I suspect it's a more easily readable syntax (though the
state variables make the IO state not bad).  I take your point about
impurity, but it still doesn't really seem right that something which
does not affect the state of the variable is impure, even though I
understand why it is impure.

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