[m-dev.] Reopened: state vars syntax sugar
Peter Schachte
schachte at csse.unimelb.edu.au
Tue Jan 30 22:47:39 AEDT 2007
Gregory James DUCK wrote:
> :- 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))? It'd
be nicer to have a syntax which does not permit semantic errors. (I know, the
current mode syntax permits semantic errors like ground>>free, but if we can
come up with a syntax that makes semantic errors, that would be preferable.
The !Inst syntax would work with any inst.
> 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. I think it's a bit less natural to think about inferring the mode
of the other argument from the one that's specified than it is to think of the
argument as a single state variable argument having a value whose inst is
specified as !Inst in the predicate's mode.
--
Peter Schachte I worry that 10 or 15 years from now, [my child]
schachte at cs.mu.OZ.AU will come to me and say 'Daddy, where were you
www.cs.mu.oz.au/~schachte/ when they took freedom of the press away from
Phone: +61 3 8344 1338 the Internet?' -- Mike Godwin
--------------------------------------------------------------------------
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