Com S 641 Lecture -*- Outline -*- * Modeling object-oriented language (chapter 5) ** modeling strategies suppose we take it as our goal to model all kinds of OO languages Q: what are our options for formalizing object-oriented languages? 1. making a big model that contains all the features 2. create a simple, flexible model that can represent all the features the book takes the second approach: - similar to the lambda calculus, at that level of abstraction - start with untyped kernel language, add types Q: why not have types in language from the beginning? Q: what's the purpose of types? Q: how do we know when we have it right? Q: what are some of the main features of object-oriented languages? - classes and objects (chapter 4): Q: can we model classes using objects? - fields and methods: Q: can we model one using the other? methods will be used to simulate fields this means that field update has to be modeled by method update (this avoid some of the problems with dynamic inheritance) - delegation and embedding (section 4.3-5): each object designates a parent object delegation means that: the parent's methods are used at run-time when the parent's method is called by delegation, self refers to the original receiver of the message embedding means that the parent's methods are copied into the child object at the time of object creation Q: what are the advantages of each? Delegation allows easier pervasive changes (intentional or not) delegation more easily allows space optimization the book uses embedding it may be interesting to investigate the opposite decision... - single and multiple dispatch: single dispatch is used in most languages, and the book - functional vs. imperative: we'll do both, although the functional one is simpler