Com S 641 Lecture -*- Outline -*- for operational-semantics * Untyped calculi (chapter 6) ** object primitives (section 6.1) Go over the primitives for methods and objects and their semantics x -- variables sigma(x)b -- method [l1=sigma(x)b1, ..., ln=sigma(x)bn] -- object o.l -- invocation o.l <- sigma(x)b -- method update Q: should the labels be distinct? Why? Q: what is the host object of a method? Q: what does a type error mean in this context? examples(section 6.1.3): [] [l=sigma(self)self].l let o = [l=sigma(self)self.[]] in o.l let ohno = [m=sigma(self)self.m] in ohno.m let o = [l=sigma(self)self.l] in o.l <- sigma(x)[] Q: how do we model fields in the calculus? Q: Why does that make sense? Q: what notations are used for fields? Q: how would you write something like clone in Java? Q: a point class, with a move method? stacks? Lists? Q: how would we and the integers to this as primitives? *** computational semantics (section 6.1.2) is Q: can we write a little step semantics for this calculus? Q: what would be the derived rules for fields? ** formal syntax and semantics (section 6.2) Q: what we need to formalize? *** the syntax (6.2.1) explain the syntax, free variables, and substitution Q: are free variables occurrences or possibilities? Q: how would you define free variables for field sugars? Q: do they match the free variables of the desugared forms? Q: what terminology from the lambda calculus is appropriate here? closed terms, alpha conversion, alpha equivalence Q: what equivalences are unique to this setting? *** reductions (6.2.2) Q: what corresponds to the top-level one-step reduction (>->) and one-step reduction (->) relations in what we've seen before? Q: what is a redex? Q: what is a context? Church Rosser theorem for the transitive closure of the reduction relation *** equational theory (section 6.2.3) Q: which are the structural rules? Q: does the equational theory allow us to prove that |- [clone =sigma(x)x] <-> [clone =sigma(y)y] ? Q: what is a judgment? Q: is alpha conversion really valid? *** operational semantics (section 6.2.4) Q: can you make a big step semantics of this? the key thing is choosing the set of results (answers) the only redexes are the invocation of methods, and method update so results are expressions without an outermost redex this leads to a notion of "weak reduction" (~~>) Q: why is it weak? Q: what kinds of correctness checks can we make, now that we have two semantics? soundness and completeness Q: is the object calculus call-by-name, or call-by-value? Q: what is an argument to a method? Q: could we make an interpreter from this? See section 6.2.5 ** encoding the lambda calculus (section 6.3) *** lambda-terms as objects translation <<.>> : lambda-term -> objects <> = x <> = <>.arg <- sigma(y)<> , for an unused y <<\x.b{x}>> = [arg=sigma(x)x.arg, val=sigma(x)<>].val examples: <<\x.x x>> = Q: what properties would we like to prove about this translation? that the usual conversion rules are preserved, however, eta conversion is not valid... *** other extensions default arguments and call-by-keyword (section 6.3.2) let? ** examples (section 6.4 and 6.5) *** fixed points Q: what would the translation of the Y operator be? fix = [arg=sigma(x)x.arg, val=sigma(x)((x.arg).arg := x.val).val] Q: what would we have to do to verify that this is actually a fixed-point operator? *** others (6.5) movable clients, backup methods, natural numbers, calculator, storage cells Q: can we do the Booleans? The natural numbers? Q: how about if then else expressions? ** traits, classes, and inheritance (section 6.6) Q: what is a pre-method? Q: what is a trait? How is it represented? Q: how is an object generated from a collection of traits? Q: how are traits and classes different? Q: how are classes modeled? Q: how does inheritance from classes work? Q: how does inheritance of traits work? Q: is inheritance done at run-time? Q: how does method override work? ** interpretations of objects (section 6.7) *** the self-application semantics (section 6.7.1) Q: how to objects differ from records of functions? Q: what are the typing problems? *** the recursive-record semantics (section 6.7.2) Q: how does this address the typing problems? Q: what are the problems with method update in this semantics? ** variations Q: what would a delegation-based approach to objects look like? Q: what would a class-based approach to objects look like? Q: how would you add privacy? Q: what would a calculus of generic functions look like?