<html>
<body>
Dear Valery,<br><br>
At 08:52 PM 10/17/2005, you wrote:<br>
<blockquote type=cite class=cite cite="">I'm a bit lost with uniqueness
typing. Could anyone help me along ?<br><br>
/1/<br>
Start = (a,f 1 a,f 2 a)<br>
where<br>
&nbsp;&nbsp; f :: !Int *{#Int} -&gt; *{#Int}<br>
&nbsp;&nbsp; f i t<br>
&nbsp;&nbsp; #! t0 = t.[0]<br>
&nbsp;&nbsp; = {t &amp; [0] = t0 + i}<br>
a :: *{#Int}<br>
a = {i \\ i &lt;- [0..9]}<br>
The code above produces ({0,1,2},{1,1,2},{2,1,2}), as if 'a' was not
unique, but I expected it to be rejected by the compiler, because 'f' is
supposed to update its unique argument in place, that is, 'a' should be
destroyed by the first application of 'f, and the second one should
fail.<br>
Where am I wrong ? Does 'f' duplicate its array argument despite the
uniqueness annotation ?</blockquote><br>
The reason that you get three arrays is because a is a function that,
when evaluated, yields a unique array. If you would have used a locally
within f, then the code would have been rejected (don't forget to remove
the type of a, otherwise it will be regarded as a local
function:<br><br>
<tt>Start = (a,f 1 a,f 2 a)<br>
where<br>
&nbsp;&nbsp; f :: !Int *{#Int} -&gt; *{#Int}<br>
&nbsp;&nbsp; f i t<br>
&nbsp;&nbsp; #! t0 = t.[0]<br>
&nbsp;&nbsp; = {t &amp; [0] = t0 + i}<br><br>
// a :: *{#Int}<br>
&nbsp;&nbsp; a = {i \\ i &lt;- [0..9]}<br><br>
</tt>This correctly produces the error messages:<br>
<tt>Uniqueness error [uniqueness_Valery.icl,5,Start]: &quot;a&quot;
demanded attribute cannot be offered by shared object<br><br>
</tt><blockquote type=cite class=cite cite="">/2/<br>
What I want actually is a struct that contains a unique array, because
the array will be updated in place several time later. The struct itself
will be copied, not updated.<br>
When I try<br>
:: Pos = {t :: *{Int}}<br>
I get &quot;inconsistent attribution of type definition&quot;, which is
fine, since whatever contains something unique has to be unique, but when
I try<br>
:: Pos = *{t :: *{Int}}<br>
I get &quot;} expected instead of ::&quot;.<br>
How to define this type ?</blockquote><br>
Your analysis is correct: uniquely attributed objects must reside in
unique objects. This is indicated by attributing the type constructor as
unique:<br><br>
:: *Pos = { t :: *{Int}}<br><br>
Regards,<br>
Peter<br>
</body>
<br>
</html>