[m-dev.] Reopened: state vars syntax sugar

Gregory James DUCK gjd at csse.unimelb.edu.au
Wed Jan 31 10:02:14 AEDT 2007


Hi,

> > :- pred main(!io::di) is det.	or
> > :- pred main(!io::!di) is det	(?)
> > I don't think it looks too bad.  Actually, now that I think about it I'd prefer
> > (!io::!di) over (!io::di).
>
> I think the real alternative would be !(io::di) rather than (!io::di).  But I
> agree, both look pretty good.
>
> Each of them has lexical problems.  !Type::!Mode requires us to add a new
> operator ::! and to separately handle !Type :: !Mode (I really don't think you
> want to support only one of them).  With !(io::di) you'll have people who want
> to write !io::di.  Either of these problems can be worked around, and there's
> really not a lot between them.
>
> But the bigger question is what !Mode means.  Can you use it with any old mode?
>  What would !out mean?  How about !uo?  or !(bound(a;b;c)>>bound(a;b))?

See my previous email, where I defined:

output(Inst >> _) = free >> Inst

and !Mode is shorthand for (Mode, output(Mode)), therefore:

!out = (out, free >> free)  = (out,unused)
!uo  = (uo,  free >> free)  = (uo, unused)
!(bound(a;b;c)>>bound(a;b)) = (bound(a;b;c)>>bound(a;b),free>>bound(a;b;c))

No semantic errors, but not very useful either.

> > I like this syntax mainly because it is concise (which is surely one of the
> > main reasons for introducing syntactic sugar).  The only funny thing is
> > understanding that !di or !in also an "out" mode as well
>
> It's a lot better than !Type::(Mode1, Mode2), but it's not any more concise
> than !Inst.

That's not quite true simply because the standard inst names
(e.g. ground,unique,etc.) seem to be longer than the standard mode names
(e.g. in,uo,etc.).

-Greg.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list