[mercury-users] semidet vs unique updating

Michael Day mikeday at bigpond.net.au
Mon Oct 15 12:17:44 AEST 2001


Consider queue__get operating on a unique queue. The normal mode of get
looks like this:

:- pred queue__get(queue(T), T, queue(T)).
:- mode queue__get(in, out, out) is semidet.

I can't see how to maintain that interface and preserve uniqueness.

:- mode queue__get(di, uo, uo) is semidet.

This won't work, as once queue__get has been called its first argument is
dead, and it can't fail and backtrack.

:- mode queue__get(ui, uo, uo) is semidet.

This will work (assuming we fudge around compiler ui mode inadequacy) but
it doesn't say what we mean; the predicate can succeed and the first
argument will still be around, requiring the predicate to make a copy of
the queue to ensure uniqueness (or lie to the compiler and face its
terrible vengeance).

Can a mode be constructed like this:

	unique >> dead on success, unique on failure ?


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