I don't know how Tcl's oo package works (I use the SNIT framework, which works differently), but I'm guessing you are seeing some sort of scope "magic".
At Sat, 8 Jun 2024 22:57:12 +0200 aotto1968 <
[email protected]> wrote:
# Hi tricky tcl OO stuff
#
# the "OtherC create test2" create the "test2" instance in the namespace of the calling instance (test1).
# the advantage is, if the calling-instance is delete the test2-instance is delete too because the
# calling-instance namespace is deleted.
#
# and now the question:
#
# is the "test2" now a "variable" or a "command" ? the reason I ask is because the "my varname test2"
# return the string with absolute ns-path of the "test2-command" bus BUT it is a command and *not*
# a variable. the test with "info exists $varname" say 0, not a variable.
#
# I check the result from "my varname test2" later with "$varname test"
oo::class create OtherC {
constructor {} {
puts "create OtherCâ[self]"
}
destructor {
puts "delete OtherCâ[self]"
}
method test {} {
puts "I'm [self]"
}
}
oo::class create OttoC {
constructor {} {
puts "create OttoCâ[self]"
OtherC create test2
}
destructor {
puts "delete OttoCâ[self]"
}
method get {} {
my varname test2
}
}
OttoC create test1
set varname [test1 get]
$varname test
puts "varname = $varname"
puts "varname exists = [info exists $varname]"
test1 destroy
resultâ¦
create OttoCâ::test1
create OtherCâ::oo::Obj13::test2
I'm ::oo::Obj13::test2
varname = ::oo::Obj13::test2
varname exists = 0
delete OttoCâ::test1
delete OtherCâ::oo::Obj13::test2
--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
[email protected] -- Webhosting Services
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)