[m-dev.] State variable syntax - last call for opinions
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Jan 31 16:50:08 AEDT 2002
Peter Schachte, Thursday, 31 January 2002:
>
> That's good, but not what I was talking about. If I write (using
> Fergus's latest syntax proposal):
>
> foo :-
> !:X = 0,
> ... stuff ...
> !:X = !:X + 1.
>
> that might translate to something like:
>
> foo :-
> X1 = 0,
> ... stuff ...
> X5 = X4 + 1.
>
> The Mercury compiler would issue a singleton variable warning for the
> latter clause because X5 only appears once. I think it should issue a
> similar warning for the former clause, too.
After more discussion here in the office, we've decided you're right:
- it should be an error for either !.X or !:X to appear without the
other somewhere in the same clause;
- also it should be an error for !.X to appear before !:X except in the
head of the clause.
> > > Is it an error to have multiple !:X in the same atom? I think it
> > > probably should be. You could give it a sensible meaning, but I think
> > > it would be too confusing to use.
> >
> > I'd rather stick with a simple, general transformation and let the
> > programmer learn to avoid baroque coding styles the hard way.
>
> But what does it mean? For example, how would you translate
>
> !:X = 0,
> !:X = !:X + 1,
> foo(!.X),
Into
X3 = 0,
X4 = X4 + 1,
foo(X4), X5 = X4,
> or
>
> !:X = 0,
> foo(!X, !X).
> foo(!.X),
Into
X7 = 0,
foo(X7, X8, X7, X8),
foo(X8),
- Ralph
--------------------------------------------------------------------------
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