Next: Class Declaration, Previous: Basic oof.fs Usage, Up: The oof.fs model [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?).
object-class ( "name" – ) oof
object-definitions ( – ) oof
object-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.
object-init ( ... – ) oof
object-dispose ( – ) oof
new, new[], :, ptr, asptr, and
[] to create named and unnamed objects and object arrays or
object pointers.
object-new ( – o ) oof
object-new[] ( n – o ) oof “new-array”
object-: ( "name" – ) oof “define”
object-ptr ( "name" – ) oof
object-asptr ( o "name" – ) oof
object-[] ( 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.
object-:: ( "name" – ) oof “scope”
object-super ( "name" – ) oof
self to get the address of the object
object-self ( – o ) oof
bind, bound, link, and is to assign object
pointers and instance defers.
object-bind ( o "name" – ) oof
object-bound ( class addr "name" – ) oof
object-link ( "name" – class addr ) oof
object-is ( xt "name" – ) oof
' to obtain selector tokens, send to invocate selectors
form the stack, and postpone to generate selector invocation code.
object-' ( "name" – xt ) oof “tick”
object-postpone ( "name" – ) oof
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.
object-with ( o – ) oof
object-endwith ( – ) oof
Next: Class Declaration, Previous: Basic oof.fs Usage, Up: The oof.fs model [Contents][Index]