[m-rev.] Add `:- mutable' declaration to the language.
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu Sep 1 15:30:06 AEST 2005
On 1 Sep 2005, at 15:11, Ralph Becket wrote:
> 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)).
>
I still think these should be supplied.
If the pure versions are supplied then they can be used without having
any knowledge of the impurity system (which can take a while to learn
to use properly, especially if you are new to Mercury).
With the pure versions there is no burden on the user to promise that
they are pure and therefore no need to understand the impurity system.
This would make the :-mutable declarations more generally accessible.
Ian.
--------------------------------------------------------------------------
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