Next: Class Declaration, Previous: Basic OOF Usage, Up: OOF [Contents][Index]
When you define a class, you have to specify a parent class. So how do
you start defining classes? There is one class available from the start:
object. You have to use it as ancestor for all classes. It is the
only class that has no parent. Classes are also objects, except that
they don’t have instance variables; class manipulation such as
inheritance or changing definitions of a class is handled through
selectors of the class object.
object provides a number of selectors:
class for subclassing, definitions to add definitions
later on, and class? to get type informations (is the class a
subclass of the class passed on the stack?).
class "name" – oof “class”
definitions – oof “definitions”
class? o – flag oof “class-query”
init and dispose as constructor and destructor of the
object. init is invocated after the object’s memory is allocated,
while dispose also handles deallocation. Thus if you redefine
dispose, you have to call the parent’s dispose with super
dispose, too.
init ... – oof “init”
dispose – oof “dispose”
new, new[], :, ptr, asptr, and
[] to create named and unnamed objects and object arrays or
object pointers.
new – o oof “new”
new[] n – o oof “new-array”
: "name" – oof “define”
ptr "name" – oof “ptr”
asptr o "name" – oof “asptr”
[] n "name" – oof “array”
:: and super for explicit scoping. You should use explicit
scoping only for super classes or classes with the same set of instance
variables. Explicitly-scoped selectors use early binding.
:: "name" – oof “scope”
super "name" – oof “super”
self to get the address of the object
self – o oof “self”
bind, bound, link, and is to assign object
pointers and instance defers.
bind o "name" – oof “bind”
bound class addr "name" – oof “bound”
link "name" – class addr oof “link”
is xt "name" – oof “is”
' to obtain selector tokens, send to invocate selectors
form the stack, and postpone to generate selector invocation code.
' "name" – xt oof “tick”
postpone "name" – oof “postpone”
with and endwith to select the active object from the
stack, and enable its scope. Using with and endwith
also allows you to create code using selector postpone without being
trapped by the state-smart objects.
with o – oof “with”
endwith – oof “endwith”
Next: Class Declaration, Previous: Basic OOF Usage, Up: OOF [Contents][Index]