12/9/15 1
OO: ¡optimizing ¡with ¡static ¡types, ¡ code-‑sharing ¡mechanisms
- 1. Prelude: ¡ C++-‑style ¡ representation
- 2. Multiple ¡inheritance
- 3. Interfaces
- 4. T
raits/mixins
Uses ¡slides ¡by ¡Steve ¡Freund
C++ ¡Run-‑Time ¡Representation
2 Point ¡object x vptr Point ¡vtable Code ¡for ¡move 3 y
C++ ¡Run-‑Time ¡Representation
2 4 red Point ¡object ColorPoint ¡object x vptr x vptr c Point ¡vtable ColorPoint ¡vtable Code ¡for ¡move Code ¡for ¡move Code ¡for ¡darken Data ¡at ¡same ¡offset Function ¡pointers ¡at ¡same ¡offset 3 5 y y
Contrast ¡with ¡Smalltalk ¡representation
2 3 x y newX:Y: draw moveDx:Dy: Point ¡object Point ¡class Template Method ¡dictionary ... 4 5 x y newX:Y:C: color draw ColorPoint ¡object ColorPoint ¡class Template Method ¡dictionary red color ...