Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2014-12-18
13:58 • Closed ticket [2960227fff]: problem with my command plus 7 other changes artifact: 9d79af840d user: dkf
2014-09-14
16:38 • Ticket [2960227fff]: 5 changes artifact: b44fe791b3 user: dkf
2012-04-10
15:31 • Ticket [2960227fff]: 1 change artifact: b3cd64ced6 user: dkf
2010-03-02
21:02 • Ticket [2960227fff]: 4 changes artifact: 2bb5012750 user: dkf
2010-03-01
20:55 • Ticket [2960227fff]: 4 changes artifact: 82a8020bea user: wiede
2010-02-28
16:12 • Ticket [2960227fff]: 4 changes artifact: 091045d569 user: wiede
16:07 • Ticket [2960227fff]: 4 changes artifact: 1f7fafa3c5 user: wiede
16:07 • Add attachment t9.log to ticket [2960227fff] artifact: 96f137faab user: wiede
13:45 • Ticket [2960227fff] problem with my command status still Open with 4 other c... artifact: a958fe888f user: dkf
13:40 • Ticket [2960227fff]: 4 changes artifact: f9ebca42c2 user: dkf
2010-02-27
22:03 • Add attachment t9.tcl to ticket [2960227fff] artifact: f724c93a31 user: wiede
22:03 • Ticket [2960227fff] problem with my command status still Open with 4 other c... artifact: aeac56a955 user: wiede
15:03 • New ticket [2960227fff]. artifact: ca4d56a044 user: wiede

problem with my command

Closed / Wont Fix2960227fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 12 years ago
Descriptionplain2010-02-27 15:03:38
Using the "my" command of an object when the object's class is created with createWithNamespace option shows that the "my" command uses the wrong namespace when created with the object. Use of createWithNamespace object for the object too fails with complaining that the namespace cannot be created, as it already exists. My quick hack was to add a flag to AllocObject and to the Class structure. the class structure has a flag use_declarer_ns, which is set to1 if the createWithNamespace option is used and the object on creation uses classPtr->thisPtr->selfCls->use_declarer_ns when calling AllocObject. I am not sure, if that's a suitable solution, but at least my example works with it. The example is in the attached file. Be aware that also the FRQ for the -use_declarer_ns option is necessary for that example to work.
wiedeplain2010-02-27 22:03:39
File Added - 364686: t9.tcl
dkfplain2010-02-28 13:40:12
I don't understand the nature of this bug. The [my] command just uses the object's private namespace because all method invocations do that. That's what standard methods are defined to do. (A different method type could do something else; the choice of which namespace to make current is part of the method implementation and not the core method system, as can be seen from the way that forwarded methods are handled.) Because it is vital that we hang some bits and pieces of state off the namespace - it's a fundamental design decision which permeates everything - we *have* to create a namespace during object creation; using an existing namespace isn't going to work.

Right now, I suspect that a custom method type might be all that you're looking for.
dkfplain2010-02-28 13:45:19
BTW, what is that example script supposed to actually output? :-)

(At a guess you're complaining about the fact that [my] isn't a global command? If so, tough. Lots of other code depends on the fact that every object has its own [my], and that each of them knows which particular object is being talked about. For one thing, it is at the heart of how to do callbacks from traces, binding scripts, etc.)
wiedeplain2010-02-28 16:07:27
File Added - 364782: t9.log
wiedeplain2010-02-28 16:12:34
The problem is, that calling an objects method, which has the use_declarer_ns flag set, this method is executed in the classes namespace. In that namespace there is no [my] command available, as that is in the object's namespace. I don't know how to call another method within that object from the executed method.
It is correct, that on the C-level I could implement a similar command, which is available in the classes namespace.

An example output is in the 2nd attachment.
wiedeplain2010-03-01 20:55:38
Having had a deeper look at the wanted behaviour, I have found out, that what I need is a command similar to the [my] command in every class namespace of the object's classes. I have added a ::oo::define itclthis part for providing that, which does provide what I need and with that the wanted functionality is available. So it is up to you Donal, if that is a bug or not, at least I have a solution for the problem.
dkfplain2010-03-02 21:02:51
I'm not quite sure where to store the information about what the subject of the "instance-my" command is.
dkf Ticket [2960227fff]: 1 change [History diff]2012-04-10 15:31:38
dkf Ticket [2960227fff]: 5 changes [History diff]2014-09-14 16:38:54
dkfhtml2014-12-18 13:58:47

Ah! I understand now.

TclOO will always create the namespace for the instance of the object; it needs to have the right deletion callback configured at the C level for object destruction to work. Without that callback, there's a gigantic memory leak. Because of that basic constraint, that namespace needs to not exist prior to the call to the createWithNamespace method.

I don't plan to allow two instances to have the same instance namespace. That would enormously complicate the cleanup code, which is already pretty tricky...

Log in (anonymous is fine) to add a comment.

Attachments: