Go backward to Object-Oriented Languages
Go up to Top
Go forward to The Nature of Self
Dynamic Scoping and Self
- Reference self to current object:
- class NAT = record
var NUM: newint;
proc SUCC = self.NUM := @self.NUM+1;
proc PLUSTWO =
call self.SUCC;
call self.SUCC
end
- class INT = inherits NAT with record
var ISNEG: newbool
proc SUCC =
if not self.ISNEG then ...
else ...; fi
end
- self is unresolved identifier:
- When class is invoked to declare object, self references are
resolved to object being declared!
Wolfgang.Schreiner@risc.uni-linz.ac.at
Id: qualification.tex,v 1.2 1996/05/02 11:53:49 schreine Exp schreine