[m-dev.] for review: improvements for record syntax

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Dec 8 16:47:37 AEDT 2000


On 08-Dec-2000, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> On Fri, Dec 08, 2000 at 11:28:47AM +1100, Fergus Henderson wrote:
> > > I don't see how you could ever implement policy (1) without the function
> > > name restriction.
> > 
> > Well, you just do the transformation as a syntactic transformation.
> > If you see `Term1 ^ Var(Term2)', you replace it with `Var(Term1, Term2)'.
> 
> Well, OK, I guess it's actually a no-currying-allowed restriction (which is
> not checkable unless you also make the function name restriction).  If Var
> is bound to the closure matrix_elt(3), then Term1 ^ Var(5) expands to
> Var(Term1, 5), which is really matrix_elt(3, Term1, 5).  But it *should* be
> matrix_elt(Term1, 3, 5), if it were really inserting the term before the `^'
> as the first argument of the second argument.

No, the idea with policy (1) [at least as interpreted by me]
is that infix `^' inserts the term on the left of the `^' as the first
*syntactic* argument of the term on the right.  With this definition,
it doesn't matter what Var is bound to, the term `Term1 ^ Var(5)'
*should* (and does) always get mapped to `Var(Term1, 5)'.

This definition is not referentially transparent, and *is not intended
to be*.  Which leads Simon Taylor to describe it as "Horrible" and
which apparently makes it completely unthinkable to Peter Schachte ;-).

However, as I said earlier, you've convinced me that policy (2)
is better, because it would leave room for the possibility of treating
field names as first-class values.

> > > That's why I'm flip-flopping to support policy (2)
> > > now.  I think there is more to be gained by allowing first-class values
> > > on the right of ^ (even if not immediately) than is lost by a somewhat
> > > confusing argument order on accessor and setter functions.
> > 
> > OK, you've convinced me.
> 
> Cool.  Is this a quorum?  Can this feature go into the Rudolph release?

We discussed this at the Mercury meeting today, and there were no
objections, so the answer to that is yes.  Simon is also planning to 
eliminate the function name restriction for `^', i.e. to map
`Field ^ Var' to `Var(Field)'.

I'd still like to hear Ralph's opinion, to see if he too is convinced
by this argument.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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