counted -- Reference counted objects in Tcl

This is a Tcl extension which allows you to implement reference counted objects and have those objects automatically destroyed when their last reference is released. The extension defines the command:

::counted::command delegateCommand ?destroyScript?

This command creates a reference counted command object and returns a handle representing the object. The handle can be used as a Tcl command to invoke operations on the object. In practice, you should store the handle in a Tcl variable or pass it as an argument to another command.

The object delegates its operations to a Tcl command. The delegateCommand will be called with the arguments passed to the handle when the handle is used as a Tcl command.

If a destroyScript script is specified, it will be executed after the last reference to the object is released.

Downloadable files

source code and compiled Windows library