In an assignment and in passing an actual argument to a function, the types of the target and the expression being assigned or passed must be equal (with noted exceptions, such as assignment of nil
to a reference type). When a function is defined, its type must be equal to the type of a function with the same name if one is in scope. Type equality is determined as follows.
adt
types are equal if and only if their data members are listed in the same order, have the same names, and have correspondingly equal types. The cyclic
attribute of members is significant. Constant and function members of an adt
do not enter into the comparison, nor does the name of the adt
type itself.
In particular, in the declarations:
A: adt { x: ref B }; B: adt { x: ref A }; the typesA
andB
are equal.
ref adt
types are equal if and only if they are references to equal adt
types.
adt
members) have equal types and appear in the same order. However, the interleaving of function members among data members is insignificant. Constant members and type members do not enter into the comparison.
self
attributes on arguments much match. Names given to arguments do no enter into the comparison.
load
expression. A load
type is compatible with a stored type if and only if the data members of the two types have the same names, the same types, and appear in the same order. Moreover, any adt
or functions used by the program executing load
must have a type equal to the corresponding members of the stored module. However, there are no restrictions on the ordering of these members, and the stored module can contain adt
or function members not present in the module declaration present in the load
program.