Tcl HomeTcl Home Hosted by
ActiveState

Google SiteSearch

Object-Oriented Programming in Tcl

Historically, Tcl has supported object-oriented programming through a variety of extensions. As of version 8.6, Tcl now includes a built-in OO system, TclOO, that is powerful enough to be used on its own while at the same time serving as a foundation for additional layered OO systems.

TclOO features include

  • Multiple inheritance
  • Class and object mix-ins
  • Class and object filters
  • Method forwarding
  • Object specialization
  • Dynamic redefinition of classes and objects
  • Full introspection

The system is flexible enough to allow both class-based and class-less (prototype) OO programming models. And of course, like everything in Tcl, nothing is forced on you. If you do not need objects in your 10-line script, TclOO stays out of your way.

At the same time, TclOO exposes sufficient functionality that permits other OO systems to be layered on top. For example, V4.0 of the [incr Tcl] OO system, modeled after the familiar C++ style of OO, is built on top of TclOO.

Notwithstanding the inclusion of TclOO, Tcl continues to support other popular OO extensions like XOTcl and the cutting edge NX.