Go backward to Inheritance Issues
Go up to Top
Go forward to Dynamic Scoping and Self
Object-Oriented Languages
- Redefined class methods via dynamic scoping.
- class NAT = record
var NUM: newint;
proc SUCC = NUM := @NUM+1;
proc PLUSTWO = call SUCC; call
SUCC
end
- class INT = inherits NAT with record
var ISNEG: newbool
proc SUCC =
if not ISNEG then NUM:=@NUM+1
else NUM:=@NUM-1; ...; fi
end
- In context INT, PLUSTWO should call new SUCC!
- In context NAT, PLUSTWO should call old SUCC.
Static scoping does not support this!
Wolfgang.Schreiner@risc.uni-linz.ac.at
Id: qualification.tex,v 1.2 1996/05/02 11:53:49 schreine Exp schreine