View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] How to overload Class destroy?

From: Uwe Zdun <uwe.zdun_at_wu-wien.ac.at>
Date: Tue, 04 Jan 2005 16:52:32 +0100

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