_________________________________________________________________
::stooop - Object oriented extension.
package require Tcl 8.3
package require stooop 4.2
namespace import stooop::*
class name body
new class ?arg arg ...?
delete object ?object ...?
virtual proc name {this ?arg arg ...?} ?body?
classof object
new object
_________________________________________________________________
This package provides commands to extend Tcl in an object oriented manner, using a familiar C++ like syntax and behaviour. Stooop only introduces a few new commands: class, new, delete, virtual and classof. Along with a few coding conventions, that is basically all you need to know to use stooop. Stooop is meant to be as simple to use as possible.
This manual is very succinct and is to be used as a quick reminder for the programmer, who should have read the thorough stooop.html HTML documentation at this point.
class name body
This command creates a class. The body, similar in
contents to a Tcl namespace (which a class actually
also is), contains member procedure definitions.
Member procedures can also be defined outside the
class body, by prefixing their name with class::,
as you would proceed with namespace procedures.
proc class {this ?arg arg ...?} ?base {?arg arg
...?} ...? body
This is the constructor procedure for the
class. It is invoked following a new invocation
on the class. It must have the same
name as the class and a first argument named
this. Any number of base classes specifications,
including arguments to be passed to
their constructor, are allowed before the
actual body of the procedure.
proc ~class {this} body
This is the destructor procedure for the
class. It is invoked following a delete
invocation. Its name must be the concatenation
of a single ~ character followed by the
class name (as in C++). It must have a single
argument named this.
proc name {this ?arg arg ...?} body This is a member procedure of the class, as its first argument is named this. It allows a simple access of member data for the object referenced by this inside the procedure. For example: set ($this,data) 0.
proc name {?arg arg ...?} body
This is a static (as in C++) member procedure
of the class, as its first argument is
not named this. Static (global) class data
can be accessed as in: set (data) 0.
proc class {this copy} body
This is the optional copy procedure for the
class. It must have the same name as the
class and exactly 2 arguments named this and
copy. It is invoked following a new invocation
on an existing object of the class.
new class ?arg arg ...?
This command is used to create an object. The first
argument is the class name and is followed by the
arguments needed by the corresponding class constructor.
A unique identifier for the object just
created is returned.
delete object ?object ...?
This command is used to delete one or several
objects. It takes one or more object identifiers as
argument(s).
virtual proc name {this ?arg arg ...?} ?body? The virtual specifier may be used on member procedures to achieve dynamic binding. A procedure in a base class can then be redefined (overloaded) in the derived class(es). If the base class procedure is invoked on an object, it is actually the derived class procedure which is invoked, if it exists. If the base class procedure has no body, then it is considered to be a pure virtual and the derived class procedure is always invoked.
classof object
This command returns the class of the existing
object passed as single parameter.
new object
This command is used to create an object by copying
an existing object. The copy constructor of the
corresponding class is invoked if it exists, otherwise
a simple copy of the copied object data members
is performed.
Environment variables
::stooop::printObjects ?pattern?
Prints an ordered list of existing objects, in creation
order, oldest first. Each output line contains
the class name, object identifier and the
procedure within which the creation occured. The
optional pattern argument (as in the Tcl string
match command) can be used to limit the output to
matching class names.
::stooop::record
When invoked, a snapshot of all existing stooop
objects is taken. Reporting can then be used at a
later time to see which objects were created or
deleted in the interval.
::stooop::report ?pattern?
Prints the created and deleted objects since the
stooop::record procedure was invoked last. If present,
the pattern argument limits the output to
matching class names.
Please see the stooop.html HTML documentation.
class object oriented C++