sclass Operation { S function; int[] registers; int outRegister = -1; *(S *function, int... regs) { registers = subArray(regs, 0, l(regs)-1); outRegister = last(regs); } } sclass Machine { O[] registers = new O[10]; new TreeMap functions; void function(S name, O implementation) { functions.put(name, implementation); } void set(int register, O value) { if (register >= l(registers)) registers = resizeArray(registers, register+1); registers[register] = value; } O get(int register) { ret _get(registers, register); } void run(Operation op) { O f = functions.get(op.function); if (f == null) fail("Unknown operation: " + op.function); int n = l(op.registers); O[] arguments = new O[n]; for i to n: arguments[i] = get(op.registers[i]); O result = callF(f, arguments); if (op.outRegister >= 0) set(op.outRegister, result); } }