[m-dev.] State variable syntax - last call for opinions
Peter Schachte
schachte at cs.mu.OZ.AU
Thu Jan 31 14:39:17 AEDT 2002
On Thu, Jan 31, 2002 at 12:44:43PM +1100, Ralph Becket wrote:
> Peter Schachte, Thursday, 31 January 2002:
> > (Using my notation above) is referring to !X before the first !:X an
> > error? Again, I think it should be.
>
> Not if !.X appears in the head of the clause.
Ok.
> > For a clause without !:X (or !!X) in the head, if the last atom
> > mentioning X has !:X in it, does this give a singleton warning? I
> > believe it should, since your binding a variable not used elsewhere in
> > the clause.
>
> There's no connection between modes and !.X and !:X - it would just be a
> convention of interpretation that !.X denotes an input and !:X an
> output.
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.
> > 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),
or
!:X = 0,
foo(!X, !X).
foo(!.X),
--
Peter Schachte The greatest dangers to liberty lurk in
schachte at cs.mu.OZ.AU insidious encroachment by men of zeal,
www.cs.mu.oz.au/~schachte/ well-meaning but without understanding.
Phone: +61 3 8344 9166 -- Justice Louis D. Brandeis
--------------------------------------------------------------------------
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