Left root inconsistently attributed

John van Groningen johnvg@cs.kun.nl
Tue, 2 Mar 1999 17:10:16 +0100


>Is there any reason why Clean compilers could not or should not
>accept
>
>    :: T0 :=3D=3D *T1
>
>as if it were
>
>    :: *T0 :=3D=3D *T1

Older versions of the compiler accepted this. I think it was changed because=
 sometimes the * was in a deeply nested type (synonym) and when the compiler=
 reported a uniqueness type error you had to examine all the used types to=
 find out whether it really was unique.

>        You probably do not want to make the Int's unique, because the
>        primitive functions on Int (+,-,...) do not return *Int because
>        of overloading.
>       =20
>One other thing.  I have a function
>       =20
>    copy_random :: RNG_State -> *(RNG_State, RNG_State)
>    copy_random (a,b,c) =3D ((a+0,b+0,c+0), (a*1,b*1,c*1))
>       =20
>because I wasn't sure that
>
>    copy_random (a,b,c) =3D ((a,b,c), (a,b,c))
>
>would give me uniqueness.  Was I unnecessarily paranoid?  Does a Clean
>compiler share structures between function inputs and results ONLY if
>I use as-patterns, or does it do common subexpression elimination for me?

Yes, only for as-patterns, except when Reuse Unique Nodes (-ou) is on, then=
 some unique structures may be reused.

In this case it doesn't matter, because the input tuple will be unboxed. The=
 result tuples can also be unboxed with a ! annotation, or may be unboxed=
 when the compiler can determine that the tuples will be evaluated after the=
 copy_random function is called.

John van Groningen