[mercury-users] string

Ralph Becket rbeck at microsoft.com
Mon Dec 6 21:28:32 AEDT 1999


> From: Fergus Henderson [mailto:fjh at cs.mu.OZ.AU]
> Sent: 03 December 1999 18:11
> 
> I think the ordinary `array' type should work just fine if you want
> immutable arrays.  Just declare your arrays to have mode `in'
> (or let the compiler's mode inference infer it, for that matter).
> I'm pretty sure that the complications with regard to modes that you
> are talking about only arise if you are trying to do 
> destructive update.

I wasn't aware that that was possible.  So the compiler will infer that
by passing a unique reference as an argument with an `in' mode will
destroy the uniqueness of that reference?  I've just gone over the
reference manual section on unique modes again and I reckon the text
would benefit from making this connection more explicit.  For example:

[after]
Mercury also provides "unique" insts `unique' and `unique(...)' which are
like 
`ground' and `bound(...)' respectively, except that they carry the
additional 
constraint that there can only be one reference to the corresponding value. 
[add]
Note that
	X is unique => X is ground
	X is unique(...) => X is bound(...)
but not the other way around.  Hence it is possible to pass unique objects
as
arguments in `in' modes, but doing so destroys uniqueness since we have
	:- mode in :: ground -> ground.
i.e. the left hand side is satisfied by a unique argument, but there is no
guarantee from the right hand side that uniqueness is preserved by the call.

Or something like that.

Cheers,

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