Search code examples
ooptclsuperclass

tcl OO yields does not refer to an object when referring to an object


When I running my (proprietary) code, I get this:

info object isa class DlgClass is:1
DlgClass does not refer to an object
    while executing
"::oo::Obj6::my Set DlgClass"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list [namespace which my] Set $args]"
    (class "::oo::Slot" method "-set" line 2)
    invoked from within
"::oo::Obj6::my --default-operation DlgClass"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 [list [namespace which my] $def {*}$args]"
    (class "::oo::Slot" method "unknown" line 6)
    invoked from within
"superclass DlgClass"
    (in definition script

The two lines of code ( 1 which generate the message, and the one before it ) are:

puts "info object isa class DlgClass is:[info object isa class DlgClass]"
superclass DlgClass

I don't understand. Doesn't the first line output (the info object isa class DlgClass is:1one) indicate that the superclass is indeed defined?


Solution

  • Apparently it happens when I do lazy evaluation of the superclass' definition from within the class block. i.e. rather than writing:

    oo::class create foo {
       source "DlgClass.tcl" ;# if needed
       superclass DlgClass
    }
    

    One needs to do:

    source "DlgClass.tcl" ;# if needed
    oo::class create foo {
       superclass DlgClass
    }
    

    And then it works. I think that it may be a bug in oo::class/tcl engine, but, as it is so easy to workaround, not a major one.