[Xotcl] Can somebody tell me the creation and destruction processes that go on "behind the scenes" in XOTcl?

Matthew Dodwell mjd at orcaspirit.co.uk
Wed Mar 1 00:25:07 CET 2006


Dear All,

I've got a question about the behaviour of the destroy / instdest methods;


The code below outputs the following:

Base init ::MyBase
Destroy
Base destroy ::MyBase
Destroyed

... which is what I would expect. However, if the "next" call in TBase
destroy is commented out, the output is:

Base init ::MyBase
Destroy
Base destroy ::MyBase
Destroyed
Base destroy ::MyBase

The extra call to destroy occurs when the command interpreter closes, so
must mean that MyBase was not properly destroyed because "next" was not
called. This is probably the intended behaviour, but it is difficult to work
it out from the examples given in
http://media.wu-wien.ac.at/doc/tutorial.html.

Can somebody tell me the creation and destruction processes that go on
"behind the scenes" in XOTcl?

Also, it would be helpful if the differences between XOTcl and other OO
languages, say C++, were highlighted as I know I have made assumptions which
turn out to be wrong.

------------------------------------------------------------------------
Here is the code:

package require XOTcl; namespace import -force xotcl::*
package require Tcl 8.4

# define a class

Class TBase

TBase instproc init {} {
 my instvar Children Parent
 puts "Base init [self]"
 next
}

TBase instproc destroy {} {
 my instvar Children Parent
 puts "Base destroy [self]"
 next
}

# do something with it

TBase MyBase

puts "Destroy"

MyBase destroy

puts "Destroyed"

# code ends

Thanks



More information about the Xotcl mailing list