[GWM] In an [itcl] [class], all [instance]s of a class share the same variable for any variable declared [common]. That is changing a common variable in one class instance changes the value for all class instances. Common variables are created (and can be used) at the time that the class is declared. package require Itcl itcl::class test { common v1 0 common v2 0 puts "Initial v1 and v2 for class test is $v1 $v2" method setv1 {v} { set v1 $v } method setv2 {v} { set v2 $v } method showvalues {} { puts "$this has commmon values $v1 $v2" } } test a test b b setv1 2 b showvalues a showvalues # then set v2 via the a object a setv2 3.14 b showvalues a showvalues Both a and b report the same values for v1 and v2 regardless of which object was used to set the value. [GWM] Jul 2007 Note that common variables can slow down your object construction. This is because (as noted in Tcl help) the common variables are reinitialised every time a new object is created. The following constructor shows an alternative which only constructs the parms variable the first time a sample object is created: package require Itcl itcl::class sample { common parms constructor {} { if {![info exist parms]} { puts "$this initialise common parms" foreach {pv} {{p1 2} {p3 3} } { lappend parms $pv } } else { puts "$this parms common already exists $parms" } } } sample a sample b sample c gives the response: ::a initialise common parms ::b parms common already exists {p1 2} {p3 3} ::c parms common already exists {p1 2} {p3 3} Showing that the initialisation only occurs once and that later created objects share the same parms values. I have a program which often creates many thousand instances of one class, and the start up time halved with the above change. ---- [Category Discussion] | [Category Itcl]