Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 84380bd2c1c5793a43090ba913f5fcbe9885a5af
Ticket: 219316ffffffffffffffffffffffffffffffffff
Garbage collection of object oriented Tcl commands
User & Date: nobody on 2000-10-26 05:10:37
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. 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?
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.2.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "10. Objects"
  10. title changed to: "Garbage collection of object oriented Tcl commands"
  11. type changed to: "RFE"