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

Gregory James DUCK gjd at csse.unimelb.edu.au
Tue Jan 30 21:36:32 AEDT 2007


Hi,

> > In general, !T::M shorthand for
> > T::M, T::output(M)
> > where output(M) represents an output mode based on the input mode:
> >
> > output(Inst >> _) = free >> Inst
> >
> > Works for the common cases.
>
> Doesn't work for separate pred/mode declarations.

Sure it does:
:- pred main(!io).
:- mode main(!di) is det.

> Doesn't look nice for predmode declarations.

Hmmm, well that's a matter of personal taste:
:- 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 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, but IMHO this is not
too bad.

-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