[Xotcl] How to overload Class destroy?

Uwe Zdun uwe.zdun at wu-wien.ac.at
Tue Jan 4 16:52:32 CET 2005


Hi,

you call "Dummy destroy" which means that you destroy the object "Dummy" 
(which happens to be a class). Thus in its class' method destroy
the *instance* that is destroyed is Dummy. "self" is used to refer to 
the current instance. Thus:

Class create ::xotcl::_destroyer -instproc destroy {args} {
   puts "DESTROY '[self]'"
   next
}

prints: 

DESTROY '::Dummy'

--uwe



Zoran Vasiljevic wrote:

>Hi!
>
>What I want to achieve is to get informed each time a Class is getting 
>destroyed. I do need to know the name of the class and its calling
>environment (namespace).
>
>What I did is:
>
>Class create ::xotcl::_destroyer -instproc destroy {args} {
>   puts "DESTROY '[self class]'"
>   puts "DESTROY '[self calledclass]'"
>   puts "DESTROY '[self callingclass]'"
>   next
>}
>Class instmixin ::xotcl::_destroyer
>
>Now...
>
>Class Dummy
>Dummy destroy
>
>... gives ...
>
>DESTROY '::xotcl::_destroyer'
>DESTROY '::xotcl::Object'
>DESTROY ''
>
>
>What I expected to get was "DESTROY 'Dummy'" or "DESTROY '::Dummy'"
>but this does not happen. Why?
>
>Thanks,
>Zoran
>
>
>_______________________________________________
>Xotcl mailing list
>Xotcl at alice.wu-wien.ac.at
>http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>  
>

-- 
Uwe Zdun
Department of Information Systems, Vienna University of Economics
Phone: +43 1 313 36 4796, Fax: +43 1 313 36 746
zdun at acm.org, uwe.zdun at wu-wien.ac.at



More information about the Xotcl mailing list