[mercury-users] semidet vs unique updating
Ralph Becket
rafe at cs.mu.OZ.AU
Wed Oct 17 15:38:21 AEST 2001
Michael Day, Wednesday, 17 October 2001:
>
> > A better solution would be to simply return an extra boolean result
> > indicating success or failure.
>
> That is:
>
> :- pred queue__get(queue(T), maybe(T), queue(T)).
> :- mode queue__get(di, uo, uo).
>
> Quite possible. I've only been kicking and screaming so much because it
> seems that I should be able to mix unique objects with semidet code. The
> declaration above is lying, or at least misleading, in that the queue
> appears to be modified regardless of the outcome, and that if you called
> it enough times it might return yes(T), when it never will, and making it
> semidet would make that point quite clear. And would allow it to be used
> in if statements, dammit.
What you really want in this case is
:- func queue__get(queue(T)) = maybe(T).
:- mode queue__get(ui) = out is det.
which could be used in if-then-elses.
I'm sure ui modes will work sooner or later.
- Ralph
--------------------------------------------------------------------------
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