(* * A generic function that tests equality for any two tuples or lists, such * that the objects are the same except for one element. * * BUT HEY, THIS CANT WORK WITHOUT ML-LIKE GENERIC TYPES, AT LEAST FOR RECORDS * IT CANT. * * UPDATE: It's not exactly clear what we were originally trying to prove here. * What we have proved is not a big suprise -- that at present, this file * checks fine since type AnyList is fully generic, and '=' is fully overloaded * for (non-function types at least). However the notion that we could have a * function that tests for equality of any two-tuples will only work because * built-in equality is overloade for all tuple types. HOWEVER, we have not * crossed the line in allowing runtime interrogation of tuple types in order * to provide generic access to their fields. *) function XEqYExceptFor(x:AnyList, y:AnyList, elem:integer) = forall (i in [1..#x]) if (i = elem) then x[i] != y[i] else x[i] = y[i]; (* * BUT HEY again, let's try a bit harder to make it work. *) obj Any; obj AnyList = Any*; (* obj AnyTuple is tuple of Any; *)