'''[http://www.tcl.tk/man/tcl/TclCmd/define.htm%|%oo::define]''', a [Tcl commands%|%built-in] [Tcl] command, defines and changes the definition of existing classes in [TclOO]. ** Synopsis ** : '''oo::define''' ''class'' ''definitionScript'' : '''oo::define''' ''class'' ''arg'' ''arg'' ?''arg ...''? If given as a sequence of ''arg''s, the ''definitionScript'' is created by making a [list] of those arguments and evaluating that as if it was given as a ''definitionScript''. Supported definitions for use in the ''definitionScript'' are: : '''constructor''' ''argList bodyScript'' : '''deletemethod''' ''name'' ?''name ...''? : '''destructor''' ''bodyScript'' : '''export''' ''name'' ?''name ...''? : '''filter''' ?''methodName ...''? : '''forward''' ''name cmdName'' ?''arg ...''? : '''method''' ''name argList bodyScript'' : '''mixin''' ?''className ...''? : '''renamemethod''' ''fromName toName'' : '''self''' ''subcommand arg ...'' : '''self''' ''script'' : '''superclass''' ''className'' ?''className ...''? : '''unexport''' ''name'' ?''name ...''? : '''variable''' ?''name ...''? ** Documentation ** [http://www.tcl.tk/man/tcl8.6/TclCmd/define.htm%|%official reference]: ** '''`forward`''' ** `[my]` can be used as the command name: ====== oo::objdefine myobject forward method2 my method1 ====== ** Precursors, `Methods`, and Exports ** '''[PYK] 2017-12-12:''' The act of creating a new method resets the current export setting for the method. In the following example, it is necessary to use '''`export`''' twice in order for the invocation of `.~` to succeed. ====== oo::class create c1 { method .~ {} { puts {c1 method} } export .~ } oo::class create c2 { superclass c1 method .~ {} { puts {c2 method} } export .~ } c2 create obj1 obj1 .~ ====== As a point of clarification, this is true even if the method is redefined within the same class (c1 here). Furthermore, in the above example, objects of class c1 (not c2) still have the method exported. In other words, the "export" designation goes away for the class in which the method is redefined. <> Command | TclOO