next up previous contents index
Next: 3.4.2 Variable Bindings Up: 3.4.1 Creating and Destroying Previous: 3.4.1.0.1 Creating TclObjects

3.4.1.0.2 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.




2000-08-24