COMMENTS FROM JOHN TANG BOYLAND ON TAPL CHAPTER 27 AND A BETTER WAY... ---------------------------------------------------------------------- Chapter 27 is unconvincing. The purpose in using Fsub is supposedly to enable us to create the method table just once per class, rather than once per object. The code indeed manages to have it create something just once for each class, but that something is a *function* that creates the method table *at every open self recursive call*! (See the "(!self r)" calls that happen during a method invocation.) In other words, the final efficiency is worse than what we ended up at the end of Chapter 18. In my class, I instead moved on to the mechanism of Chapter 32, where the methods are separated from the state. I stay with imperative object which means that "inc" has a type I can handle with just Fsub (I don't need Fomegasub). (Of course the Object and XXXM operators have to be sugar, but this is fine, since we don't need to quantify over them (yet)). I can handle our friends, SetCounterClass and InstrSetCounterClass with open recursion using references. setget, sendinc et al don't even need Fsub. The use for Fsub comes in the Helper functions for creating the method tables: e.g.: setCounterMethodsH = lambda R <: SetCounterRep . lambda self : Source (SetCounterM R) . let super = counterMethods in {inc = lambda rep : R . (!self).set rep (succ((!self).get rep)), get = super.get, set = lambda rep : R . lambda n : Nat . rep.c := n } as SetCounterM R; setCounterMethods = let vtable = ref dummySetCounterMethods in (vtable := setCounterMethodsH[SetCounterRep] vtable; !vtable); (Here I'm using the SetCounterM operator as sugar.) Then when we try to add clone, we find that we need higher-order typing (Chapter 29-31 stuff): CloneM R = { clone : R -> R }; /* could be sugar */ Clone = Object CloneM; /* still sugar */ sendclone = lambda M <: CloneM . /* not sugar, need Fomegasub */ lambda c : Object M . let {R, obj} = c in {* R, { state = obj.methods.clone(obj.state), methods = obj.methods }} as Object M; IMHO, I think this does a nicer transition to Chapter 29 than the current Chapter 27.