#3834 self.export problem (?)

obsolete: 8.5b2
closed-fixed
8
2007-11-09
2007-11-02
jima00
No

is this a problem with self.export?

package require TclOO
namespace import ::oo::*

class create ::WEA {
method WEA {
args
} {
puts {*}$args
}
}

define ::WEA self.export WEA

::WEA WEA WEA
unknown method "WEA": must be WEA, create, destroy or new

Discussion

  • jima00
    jima00
    2007-11-09

    Logged In: YES
    user_id=1928331
    Originator: YES

    I think it might be related with the observation things go different having used create or define upon objects in TclOO.

    Here is an example of what I mean:

    package require TclOO
    ::oo::object create ::OBJ {
    method FOO {args} {puts {*}$args}
    }
    puts "Methods: [info object methods ::OBJ -all]" ;# <---- GIVES "Methods: "
    ::oo::define ::OBJ {
    method BAR {args} {puts {*}$args}
    }
    puts "Methods: [info object methods ::OBJ -all]" ;# <---- GIVES "Methods: BAR"

    Is this as intended to be?
    Should I always use "new" and then ::oo::define everything apart?

    Thanks in advance.

     
    • priority: 5 --> 8
     
  • Logged In: YES
    user_id=79902
    Originator: NO

    OK, there's a few problems here.

    Firstly, in your issue below the problem is that the default constructor for oo::object does absolutely nothing at all, and ignores all arguments. Use a subclass of oo::object to define your own behaviour, perhaps like this:
    oo::class create myObject {
    constructor {script} {::oo::define [self] $script}
    }

    Secondly, the main point of this bug report *is* a bug. The bug is that the "export record" for the undefined object method "WEA" is being interpreted as a real method when generating the error message. Oops!

     
    • status: open --> closed-fixed