[mercury-users] Self-referential data structures
Warwick HARVEY
warwick at cs.mu.oz.au
Mon Dec 1 03:14:21 AEDT 1997
Fergus Henderson <fjh at cs.mu.OZ.AU> writes:
> I have just thought of another solution. We could provide a new
> procedure in the `store' module to create a circular element.
> This procedure would take as an argument a function which when
> given a reference (mutvar) to type T produces a value of type T.
>
> :- pred new_cyclic_mutvar(func(mutvar(T, S)) = T, mutvar(T, S),
> store(S), store(S).
> :- mode new_cyclic_mutvar(in, out, di, uo) is det.
This seems quite an acceptable solution to me. Of course, I'd probably call
it "new_self_mutvar" or "new_selfref_mutvar" instead, because it is needed
for any self-referential data structure, whether it is cyclic or not.
Warwick
More information about the users
mailing list