Hi, I just joined this list to get this help. I am seeing this behaviour. It is giving lot of inconvenience to me. I want to know if it is a bug or not -?. In short, if I have a children object as the same name as parent object's proc/instproc . The parent object's method is not getting called.
Here is a sample code.
Object a Object a proc name {} { return "I am valli" } a name # returns "I am valli" Object a::name # Child object with same name as the proc a name # returns ::a::name and not the previous message
Is this the desired behaviour. Is there any workaround.
Regards Vallinayagam valli@ezorder.in
On Wed, 22 Nov 2006, V.K.Vallinayagam wrote:
Here is a sample code.
Object a Object a proc name {} { return "I am valli" } a name # returns "I am valli" Object a::name # Child object with same name as the proc a name # returns ::a::name and not the previous message
Is this the desired behaviour. Is there any workaround.
It's probably not desirable but if you think about it, you can see why that is happening. Objects are basically implemented as namespaces (well, at least they were at some point). A method is a proc inside a namespace. Thus a::name is the proc for that method. Now, objects are also commands. Placing it inside the namespace will create, well, the command a::name, thus overriding the method.
I do agree that this is not perhaps the best of behaviours and not expected. I'm not sure if child objects could be placed inside their own 'children' namespace. Uwe or Gustaf can probably comment on that.
One workaround is to create a 'children' child object yourself inside a. Then place all the objects as children of it. The downside is that the parent of those objects will now be an object called 'children'. The parent of it will be 'a'.
On Wed, 22 Nov 2006, Kristoffer Lawson wrote:
It's probably not desirable but if you think about it, you can see why that is happening. Objects are basically implemented as namespaces (well, at least they were at some point). A method is a proc inside a namespace. Thus a::name is the proc for that method. Now, objects are also commands. Placing it inside the namespace will create, well, the command a::name, thus overriding the method.
OK, I checked and the documentation does actually mention this behaviour so I guess it is desired. Check: