In addition to the insts mentioned above (
bound(…)), Mercury also provides “unique” insts
unique(…) which are like
bound(…) respectively, except that they carry the
additional constraint that there can only be one reference to the
corresponding value. There is also an inst
dead which means
that there are no references to the corresponding value, so the compiler
is free to generate code that reuses that value.
There are three standard modes for manipulating unique values:
% unique output :- mode uo == free >> unique. % unique input :- mode ui == unique >> unique. % destructive input :- mode di == unique >> dead.
uo is used to create a unique value.
ui is used to inspect a unique value without
losing its uniqueness.
di is used to deallocate or reuse the memory
occupied by a value that will not be used.
Note that a value is not considered
unique if it might be
needed on backtracking. This means that unique modes are generally
only useful for code whose determinism is
bound instantiatedness trees, there is no alternative
unique instantiatedness trees.