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'.