Deletion of TclObjects

The delete operation destroys the interpreted object, and the corresponding shadow object. For example, [scheduler]use-scheduler../ns-2/ns-lib.tclSimulator::use-scheduler uses the delete procedure to remove the default list scheduler, and instantiate an alternate scheduler in its place.
        Simulator instproc use-scheduler type {
                $self instvar scheduler_

                delete scheduler_ # first delete the existing list scheduler;
                set scheduler_ [new Scheduler/$type]

As with the constructor, the object destructor must call the destructor for the parent class explicitly as the very last statement of the destructor. The TclObject destructor will invoke the instance procedure delete-shadow, that in turn invokes the equivalent compiled method../Tcl/Tcl.ccTclClass::delete_shadow to destroy the shadow object. The interpreter itself will destroy the interpreted object.

Tom Henderson 2011-11-05