Objects in Simula Class a procedure that returns a pointer to its activation record initialization code always run as procedure body Object closure created by call to a class Object access access Memory management = garbage collection simula Same idea: FB_Player class: Variables: uniNum, height, weight Methods: (accessors) BMI, lessBMI other subclass QB variables: rating Methods: (accessors) amIBetter ref(FB_player) fb; ref(QB) qb; fb :- new fbPlayer(55,75,250); qb :- new QB(12,73,220,101); fb.lessBMIthan(qb); draw stack diagram FB_Player class Class Name -- FB_player Super Class -- Object class var -- Max_uni_num instance var -- uniNum height weight class messages and methods -- comment: Constructors mainly newUni:u Height:h Weight:w || ^ self new uniNum:u height:h weight:w instance messages and methods -- comment: accessing instance values uniNum:u height:h weight:w || uniNum <- u height <- h weight <- w uniNum || ^uniNum height || ^height weight || ^weight BMI || ^(weight/height) lessBMIthan other || ^ (self BMI) < (other BMI) Class Name -- QB Super Class -- FB_player Class var -- Max_QB_Rating instance var -- rating Class messages and methods-- newQBR:r Uni:u Height:h Weight:w || ^ self new uniNum:u height:h weight:w rating:r instance messages and methods Rating || ^ rating amIBetter other || ^ ((self Rating > other rating) && (self BMI < other BMI)) Class methods shown in dictionary, but lookup procedure distinguishs class and instance methods Instance variables are hidden but may be manipulated by subclass methods subtyping B<:A B can be used wherever an A is called for. is B=A ok? is A=B ok? What about for functions? B<:A Int<:Num say we have x: t->Num y: t->Int which one is the subtype? y what about v: Num->t w: Int->t v reference variables ref(A). Can use them to read C = val (ref (A)) legal? val (ref(A)) = C good? so, if B<:A, does ref(B)<:ref(A)? signature ref(A) fun get : unit -> A fun set : A -> unit end signature ref(B) fun get : unit -> B fun set : B -> unit end