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

Peter Schachte schachte at csse.unimelb.edu.au
Tue Mar 6 10:45:49 AEDT 2007


Jonathan Morgan wrote:

> If you prefer, a value !X should expand in some way to a !.X, !:X
> (previous state, next state pair).  Your proposed change does not
> maintain this, so it destroys the expected semantics.

If it makes you feel better, you can see it as expanding to a pair in which the
previous value is simply ignored.  Nothing wrong with that.

>> It just seems untidy and non-orthogonal that I can write
>>
>>         !Position ^ x := 7,
>>         !Position ^ y := 42
>>
>> but not the equivalent
>>
>>         !Position := position(7,42).
> 
> I don't consider it equivalent.

If you accept my semantics for !X := Term, they are logically equivalent.  My
point is that it's pretty natural to expect to replace the first sequence with
something similar looking that replaces both x and y in one go.  It's a bit
surprising to instead have to replace !Pos ^ x := 7, !Pos ^ y := 42 with !:Pos
= position(7,42).  Whoa!  Why does the colon jump to the left like that when I
want to replace the whole term?  Why doesn't it look similar?

> I would consider it a
> sharp edge being able to write:
> 
> !:X = Term1, !X := Term2
>
> There is something magical and undesirable about being able to do the
> same thing in two different ways just be moving the `:'.  I would
> prefer to limit the number of ways that an equivalent thing can be
> done unless it leads to inconsistencies in the language.  In this case
> I can see no inconsistency in the resultant language structure

I'm arguing that !X ^ x := Term1 is a special case of !X := Term2, where Term2
is like the original term, but with its x component replaced with Term1.  You
and Julien see it as something completely different.  I think this difference
in perspective is because I want to think of !X as a different sort of
"variable" that has a sequence of possibly different values throughout the
clause, whereas I gather you want to think of it as standing for a different
pair of variables in each place it occurs.  That view actually doesn't accord
well with the !X ^ x := Term syntax very well at all, whereas mine does.

To me, the best thing about the !X notation is not avoiding having to write X1,
X2, X3,... throughout the clause.  The best thing is having a simpler mental
model, and simpler syntax, for having a value evolve through the execution of a
clause.  This is something imperative languages do well, since it's their
foundation, so it seems reasonable to pinch their syntax.

-- 
Peter Schachte              You can fool all of the people some of the time;
schachte at cs.mu.OZ.AU        you can fool some of the people all of the time,
www.cs.mu.oz.au/~schachte/  but you can't fool all of the people all of the
Phone: +61 3 8344 1338      time. -- Abraham Lincoln
--------------------------------------------------------------------------
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