No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] Can somebody tell me the creation and destruction processes that go on "behind the scenes" in XOTcl?
From: Matthew Dodwell <mjd_at_orcaspirit.co.uk>
Date: Tue, 28 Feb 2006 23:25:07 -0000
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
Date: Tue, 28 Feb 2006 23:25:07 -0000
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