stooop

(Simple Tcl Only Object Oriented Programming)

This README describes stooop (a Simple Tcl Only Object Oriented Programming scheme) version 2.2.1. Stooop is implemented in a single sourceable file and uses simple techniques to provide object orientation to the great Tcl language.

The distribution is available on the alcatel info on Neosoft in the file stooop-2.2.tar.gz.

If you know C++, stooop will be easy to use for you. Using the familiar new, delete and virtual keywords and a few coding conventions, you can start object oriented Tcl code right away, as the following simple example shows:


source stooop.tcl

proc circle::circle {this canvas diameter} {
    set circle($this,diameter) $diameter
    set circle($this,canvas) $canvas
    set circle($this,id) [$canvas create oval 0 0 $diameter $diameter]
}

proc circle::~circle {this} {
    $circle($this,canvas) delete $circle($this,id)
}

proc circle::move {this x y} {
    $circle($this,canvas) move $circle($this,id) $x $y
}

pack [canvas .c]
set c [new circle .c 50]
update; after 1000
circle::move $c 10 10
update; after 1000
delete $c

Stooop supports single and multiple inheritance, data encapsulation (all member data is public), dynamic binding and runtime type identification. Member data is automatically unset when objects are deleted.

As stooop is entirely written in Tcl, it will run on all Tcl supported platforms, including Windows and the Mac Intosh, if you have Tcl version 7.5. It also works with version 7.4, of course. Additionally, stooop is also available as a C dynamically loadable extension for maximum performance (see the file stooop.c for more information on how to create the library).

Stooop works be redefining the Tcl proc command, so that object oriented helper code is added to member procedures. The new, delete, virtual and classof operators are implemented as Tcl procedures, or alternatively dynamically loadable as an extension for better performance.

Stooop was implemented with a constant concern for performance. Member data is stored in Tcl associative arrays, which are best for random data access. Object oriented helper code is kept as small and efficient as possible. Typically, only a couple of Tcl lines are added to a member procedure definition. Program startup time will be slightly increased due to proc preprocessing, but runtime overhead is kept to a minimum. Use of object oriented techniques may actually improve the performance of your code.

A full HTML documentation, HTML class browser, simple demo script, graphical demo with composite pattern, test files and manual pages are provided. You may also run the test program and look at the test scripts for examples.

Whether you like it (or hate it), please let me know. I would like to hear about bugs and improvements you would like to see. I will correct the bugs quickly, especially if you send me a test script.

You will be able to find it in the code section of your favorite Tcl/Tk mirror site or directly at neosoft.com.

I can also email a copy to you (please tell me your favorite format, MIME or uuencoded, compressed tar, gzipped tar or zip) in case you cannot find it.

Jean-Luc Fontaine