[mercury-users] another uniqueness question

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Oct 4 03:00:09 AEST 1999


On 04-Oct-1999, Robert Ernst Johann JESCHOFNIK <rejj at cat.cs.mu.OZ.AU> wrote:
> Just a quick question..
> 
> Is there any way to print out some arbitary unique object, without
> destroying it's uniqueness?

For that you want `ui' (i.e. `unique -> unique') modes.
Currently `ui' modes don't work, for the same reason that nested
unique modes don't work, namely lack of alias tracking in the mode
analyser.

A work-around is to use the following:

	:- pred print_uniq(T, T, io__state, io__state).
	:- mode print_uniq(di, uo, di, uo) is det.

	print_unique(X0, X) -->
		{ unsafe_promise_unique(X0, X) },
		print(X0).

Alternative you can use `copy' instead of `unsafe_promise_unique',
but of course that has an unfortunate efficiency cost.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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