This page describes how to migrate between [XOTcl] and [TclOO]. The direction is not important because there are good arguments to use both object oriented frameworks like supported tcl versions, speed or availability in tcl core. By programming [xotcl-light] I have fronted some discrepance in functionality or even quite different meaning. Although TclOO seems to by quite influenced by XOTcl is was changed. I you want to run XOTcl code without XOTcl extension try [xotcl-light] **next command** * XOTcl supports '''next''' command without arguments which is shortcut for just passing all arguments * In XOTcl '''next''' will be just ignored if there is no parent implementation in TclOO it will lead to error message (unknown command) **name and namespace** TclOO disinquish between name and namespace. For XOTcl it is the same but XOTcl will not create the namespace at once (for performance reasons) you need to call '''requireNamespace''' In TclOO you need to be carefull about it. It could be that name and namespace are the same but not always. For objects created per '''new''' name and namespace are same. By objects created per '''create''' ther are different ====== oo::class create A { method getName {} { self object } } set o1 [A new] set o2 [A create mya] info object namespace $o1 $o1 getName info object namespace $o2 $o2 getName # we get ::mya ====== creating namespace for XOTcl object ====== $obj requireNamespace ====== **nesting objects** XOTcl supports so called nested objects. It is very useful to manage object life time (! there is no garbage collections in both oo extensions) ====== Class create A set a [A new] set child [A new -childof $a] $a info children $child info parent $a destroy # $child is also destroyed ====== In TclOO this can be simulated by using unexported method cls createWithNamespace name nsName ?arg ...? ====== oo::class create A { self method createChildOf {object name args} { set ns [info object namespace $object]::$name my createWithNamespace $ns $ns {*}$args } } set a [A new] set child [A createChildOf $a child] $a destroy ====== **instvar and variable** This methods holds the instance variable into method context. The TclOO '''variable''' accept only one argument **XOTcl parameters** XOTcl support shortcuts for parameter ====== Class A -parameter p set a [A new -p v1] $a p $a p 23 ====== This can be easy simulated in TclOO by using some generic getter and setter and forward. passing '''-{name}''' is constructor to '''{name}''' method is some trick but maybe not the best XOTcl idee because some other problems with it. ====== oo::class create A { method parHandler {parName args} { my variable $parName set $parName {*}$args } method createParameter par { oo::objdefine [self] forward $par [self] parHandler $par } } set a [A new] $a createParameter p $a p 2 $a p ======