[m-rev.] For review: State-variable record update transformation

Jonathan Morgan jonmmorgan at gmail.com
Mon Mar 5 14:42:23 AEDT 2007


On 3/5/07, Peter Schachte <schachte at csse.unimelb.edu.au> wrote:
> Julien Fischer wrote:
> > On Fri, 2 Mar 2007, Peter Schachte wrote:
> >> If you can write
> >>
> >>     !X ^ f1 ^ f2 := Expr
> >> and
> >>     !X ^ f3 := Expr
> >>
> >> it seems a bit inconsistent not to be able to write
> >>
> >>     !X := Expr
> >
> > I don't think it is inconsistent not being able to write that.  The
> > proposed syntatic sugar is for field updates in combination with
> > state variables.  Field updates are recognised by the presence of the
> > field accessor, '^', in addition to ':='.
>
> All true, but beside the point.  My point is about people's natural expectation
> and intuition.  If you can use := to replace part of a term, it seems a pretty
> natural generalisation to use it to replace the whole term, particularly since
> that's how that syntax works in Algol-like languanges.  It's a bit strange to
> tell people not to think of state variables as allowing destructive update, but
> then provide a syntax widely used in other languages for destructive update to
> do something very much like destructive update in Mercury.  It looks and quacks
> too much like a duck for the denials to carry much weight.

This change is a syntactic sugar, done for convenience.  The syntax
you suggest provides no additional convenience, and does not strike me
as at all natural.  The reason why is exactly as Julien said: in
Mercury, the `!' operator is used to indicate an operation on the
current state to derive the next state.  Allowing !Var := Term as a
synonym for !:Var = Term destroys these semantics, as it completely
ignores the previous state.  I do not expect Mercury to work like
that, and I do not wish it to work like that.

Jon
--------------------------------------------------------------------------
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