[mercury-users] io__io == io__state

Michael Day mikeday at bigpond.net.au
Wed Jul 25 12:31:13 AEST 2001


A proposed syntactic addition:

:- type io__io == io__state.

Which would convert definitions like this:

:- pred do_stuff(int, io__state, io__state).

into

:- pred do_stuff(int, io, io).

for a saving of 14 characters. Ah you say, I left out the module
qualification on the second version. Yes, but it's still readable, isn't
it. Whereas leaving it out on the first version saves very little space
and decreases readability considerably:

:- pred do_stuff(int, state, state).

what state are we talking about here, eh?

In a way, this looks similar to the proposal (from Peter Ross?) for a
syntax extension to allow:

:- io pred do_stuff(int).

It's not particularly meaningful (passing in "the io state"  makes a lot
more sense than passing in "the io") but it saves typing and reduces the
irritation of writing predicates that perform io.

:- pred main(io::di, io::uo) is det.

Don't you just want to hug that declaration? I know I do.

:- pred main(io, io).
:- mode main(di, uo) is det.

Can't you appreciate the symmetrical beauty? Isn't this going to help
people writing their first Hello, world! in Mercury and tackling io for
the first time? Well, maybe.

Michael

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list