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!
Author: Wolfgang Schreiner
Last Modification: May 14, 1998