(* * This is a far-from-finished attempt to duplicate the ML-style for loops in * classes-archive/530/examples/ml/for.ml. Two immediate problems/issues are * the currently non-existent syntax for parameterized obj defs, and the * restrictued type expression forms in op signatures. *) obj LoopBody(?vars) = op(integer,?vars)->(?vars); obj LoopVars(?x) = ?x; func for(start:integer, until:integer, by:integer, vars:?V, body:LoopBody(?V)) = ( if start > until then [] else ( let result = body(start, vars); for(start+by, until, by, result, body) + [result]; ); ); -- Can't run next line, since it currently infinitely recurses. --> for(1, 10, 2, nil, lambda(i:integer,vars:empty) print(i); print("\n"));