This page is intended for collecting some of the internals of itcl for being able to discuss some wanted enhancements in Tcl core for use by itcl. At the moment I ([apw]) am just dumping my ideas and I will clean that up later on. Classes in itcl always handled as namespaces, that means every class in itcl corresponds to a namespace with the same name. Example for classes used later on: ====== ::itcl::class cl1 { # class commons public common c1pub c1pub protected common c1pro c1pro private common c1pri c1pri # class variables public variable v1pub v1pub protected variable v1pro v1pro private variable v1pri v1pri # class procs public proc p1pub {args} { puts stderr "p1pub" } protected proc p1pro {args} { puts stderr "p1pro" } private proc p1pri {args} { puts stderr "p1pri" } # class methods public method m1pub {args} { puts stderr "m1pub" } protected method m1pro {args} { puts stderr "m1pro" } private method m1pri {args} { puts stderr "m1pri" } } ::itcl::class cl2 { inherit cl1 # class commons public common c2pub c2pub protected common c2pro c2pro private common c2pri c2pri # class variables public variable v2pub v2pub protected variable v2pro v2pro private variable v2pri v2pri # class procs public proc p2pub {args} { puts stderr "p2pub" } protected proc p2pro {args} { puts stderr "p2pro" } private proc p2pri {args} { puts stderr "p2pri" } # class methods public method m2pub {args} { puts stderr "m2pub" } protected method m2pro {args} { puts stderr "m2pro" } private method m2pri {args} { puts stderr "m2pri" } } ::itcl::class cl3 { inherit cl2 } ====== will create a namespace (and a class) ::cl1, ::cl2 and ::cl3 The inherit command determines how the class hierarchy is built. In the above case cl3 inherits cl2 (has a "superclass" cl2) and cl2 inherits cl1. This is mostly equivalent with setting namespace path to: cl3, cl2, cl1. Methods in itcl classes are similar to procs with the difference, that they only can be called from an object created for a class and they have a protection level (see below). It is also possible to have procs in a class, these procs can be called like procs in a namespace depending on the protection level. Variables in itcl classes are similar to namespace variables with the difference, that they only can be accessed from an object created for a class when calling a method and they have a protection level (see below). Commons in itcl classes are similar to namespace variables and they can be accessed like namespace variables depending on the protection level. So the lookup of methods and variables is done starting in namespace cl3, then cl2 and then cl1. As every method in itcl is called in the namespace of its class lookup for variables and methods for a method in class cl2 starts in cl2 and continues in cl1. A method in cl3 starts lookup in cl3, then cl2 and then cl1. Protection levels: Itcl has 3 protection levels: Public, protected and private. public protection level allows to access a variable from every method or proc tied to an itcl object and from the outside using the special methods configure and cget of an itcl object. protected protection level allows to access a variable from every method or proc tied to an itcl object in the class where it is defined and in all derived classes. private protection level allows to access a variable from every method or proc tied to an itcl object only in the class where it is defined. The same definition as for variables holds for commons with the difference, that instead of an object the class(namespace) must be used. ---- !!!!!! %| [Category Package] - [Category Object Orientation] - [Category Itcl] |% !!!!!!