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