Overview
| Artifact ID: | 84380bd2c1c5793a43090ba913f5fcbe9885a5af |
|---|---|
| Ticket: | 219316ffffffffffffffffffffffffffffffffff
Garbage collection of object oriented Tcl commands |
| User & Date: | nobody on 2000-10-26 05:10:37 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 3678 RFE Version: 8.2.1 SubmitDate: '1999-11-23' LastModified: '2000-04-03' Severity: LOW Status: UnAssn Submitter: techsupp ChangedBy: hobbs OS: All FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: Chris Oliver DesiredBehavior: Several packages such as TclBlend and TclMico implement a form of automatic garbage collection for Tcl commands that represent object instances (Java and CORBA respectively). However they do this with a rather gross hack, namely by overwriting the global "cmdName" Tcl ObjType with their own implementation. The replacement implementation deletes such a command from the interpreter when the the last Tcl_Obj that references it is destroyed. A couple of minor changes to the Tcl core would allow these and other object oriented Tcl extensions to provide the convenience of automatic garbage collection to the script writer, without resorting to such hacking. I will describe these changes in terms of a possible implementation, however other ways of achieving the same result are possible: 1. Add the following new interface: TclCommand Tcl_CreateObjCommandEx(Tcl_Interp * interp, char * cmdName, Tcl_ObjCmdProc * proc, ClientData clientData, Tcl_CmdDeleteProc * deleteProc, /* boolean*/ int collectMe); 2. Add a corresponding field to struct Command: struct Command { ... int collectMe; }; Tcl_CreateObjCommandEx uses the current implementation of Tcl_CreateObjCommand but also assigns the value of its collectMe parameter to the collectMe field of the created struct Command. Tcl_CreateObjCommand can be reimplemented as Tcl_CreateObjCommandEx(interp, cmdName, proc, clientData, deleteProc, 0); 3. Modify `tclExecute.c`FreeCmdNameInternalRep to check the reference count of the Command struct it points at; if it is about to reach one (i.e. the only reference will be that of the Namespace hash table) and its collectMe field is non-zero, then call Tcl_DeleteCommandFromToken on the Command pointer. At any rate, the basic idea is that Tcl would ask the command's implementation if it wants to take action when there are no further references to it. Comments? - foundin changed to: "obsolete: 8.2.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "10. Objects"
- title changed to: "Garbage collection of object oriented Tcl commands"
- type changed to: "RFE"