[m-rev.] Add `:- mutable' declaration to the language.

Ralph Becket rafe at cs.mu.OZ.AU
Thu Sep 1 15:11:36 AEST 2005


Ian MacLarty, Thursday,  1 September 2005:
> On Thu, 1 Sep 2005, Ralph Becket wrote:
> >
> > :- semipure pred get_x(int::out(ground)) is det.
> > :- impure   pred set_x(int::in(ground)) is det.
> > :-          pred initialise_mutable_x(io::di, io::uo) is det.
> 
> Can we have pure versions of get_x and set_x which take the I/O state?

Sure, just write

:- pred get_x_io(int::out, io::di, io::uo) is det.
get_x_io(X, !IO) :- promise_pure(semipure get_x(X)).

:- pred set_x_io(int::in, io::di, io::uo) is det.
set_x_io(X, !IO) :- promise_pure(impure set_x(X)).

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



More information about the reviews mailing list