dkf has been doing OO, too - here [L1 ] is his pure-Tcl approach with the following features:
- requires Tcl 8.5 (dict)
- about 16KB of size
- prototype-based, but which has a class-based face built on top
- in an earlier phase, presented at the 2004 Tcl convention (Powerpoint: [L2 ] PDF: [L3 ])
Here's the next version, oo3.tcl[L4 ]
Current methods of the Object class/object:
- !
- Return the object's persistent state handle
- ?
- Convert a persistent state handle to a callable object
- addRef
- Increment the object's reference count
- as
- Bind object lifetime to the lifetime of a (presumably local) variable
- clone
- Produce a copy of the object, returning the name of the new object
- constructor
- Magic method called from new command
- delRef
- Decrement the object's reference count and delete if reaches zero
- delegate
- Arrange for a method (or all unknown methods if method is *) to be executed by another object (or object-like entity like a Tk widget)
- delete
- Delete the object, calling any destructor defined
- derive
- Create a new object through subclassing
- destructor
- Callback for when the object is deleted
- eq
- Is the argument object equal to this object?
- get
- Read an object field
- get parent
- Return the parent/superclass object, or empty string if no parent exists
- isa
- Test if the object is derived from another one
- linkArray
- Return the name of an array that is linked to the given dictionary-containing field
- linkVar
- Return the name of a variable that is linked to the given field
- methods
- Introspect and create object methods
- property
- Label the field as a property (bound to local variables when executing this object's methods)
- return
- Undo the linking set up with as and return the object
- set
- Write an object field
- unset
- Destroy an object field
Public helper procedures:
- super
- Call method using superclass's definition
- new
- Create a new object (based on the given "class" object) and call its constructor
The code has a self-test mode too, of course. This currently does some timing tests, and demonstrates the capabilities of the code in relation to error handling, variable linking and delegation.
Provided subclass-like objects are Collection, List, UniqueList, and Map which together form a basic aggregate type framework.
lv is some background, alternative to the paper, or the paper or powerpoint or something available?
DKF: Not yet. :^)
Look at Conference Slides for pointers.
Category Object Orientation