FindDif:
PUBLIC PROC [ a, b:
REF
ANY ]
RETURNS [ fieldNames:
LIST
OF Rope.
ROPE ] =
NIL means no difference
BEGIN
tva, tvb: AMTypes.TV;
typea: AMTypes.Type;
TRUSTED {
tva ← AMBridge.TVForReferent[a, readOnly];
tvb ← AMBridge.TVForReferent[b, readOnly];
};
typea ← AMTypes.TVType[tva];
IF AMTypes.TVType[tvb] # typea THEN ERROR;
fieldNames ← NIL;
FOR i: AMTypes.Index
DECREASING
IN [1..AMTypes.NComponents[typea]]
DO
tvac: AMTypes.TV = AMTypes.IndexToTV[tva, i];
tvbc: AMTypes.TV = AMTypes.IndexToTV[tvb, i];
IF NOT AMTypes.TVEqual[tvac, tvbc] THEN fieldNames ← CONS[AMTypes.IndexToName[typea, i], fieldNames];
ENDLOOP;
END;