(* * Illustration of an apparently polymorphic function, effected via generic * instantiation. *) obj MList = MObj* (* A generic list of multipliable objects *) ops: LG2(l:MList)->MObj; (* This explicit op decl enables apparent *) end; (* polymorphism of the function LG2. *) obj MObj (* A generic multipliable object *) ops: (* This op decl constrains the possbile *) "_*_"(ListElem,ListElem)->ListElem; (* instances (including where *) end; (* substitutions) of MObj. *) op LG2(l:MList)->MObj (* A generic (apparently polymorphic) *) begin (* function on the generic MList object *) foreach (i in l) suspend i*2; end; end; obj MIntList extends MList (* An integer extends MList, which *) where: MObj = integer; (* effects creation of the instance fcn *) end; (* LG2(l:MIntList)->integer *) op Test begin var l: MIntList; set l = [1,2,3]; print(LG2(l)); (* This calls the instance function, *) print(LG2(([1,2,3]))); (* as does this. *) end; (* * The remainder of the file is just a bit more fiddling around. *) obj intlist = integer*; op F()->() begin var i:integer; var l:intlist; foreach (i in [1..10]) print(i); end; foreach (item in l) print(item); end; set l = [1,2,3]; end;