An incestuous union is an union that contains two or more alternatives whose modes are firmly related. Two modes M1 and M2 are firmly related if it would be possible to coerce a value of mode M1 to a value of mode M2 in a firm context, or to vice versa.
Consider the following union mode definition:
mode datum = union (int,ref int,proc int);
This union is incestuous, as both ref int
and
proc int
values can be coerced to int in a firm
context, by dereferencing and deproceduring respectively. If allowed
in the language, this would lead to an ambiguity. After the
assignation in the following example, the value stored in the union
variable mydatum
may either an int
or a
ref int
:
int var; datum mydatum := var;
To avoid these ambiguities incestuous unions are not allowed by the language and should be reported in compile-time errors by Algol 68 compilers.