Skip to content
Tcl Source Code History Of Ticket 219316
Login

History Of Ticket 219316

Artifacts Associated With Ticket 219316

  1. Ticket change [84380bd2c1] (rid 117508) by nobody on 2000-10-26 05:10:37:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "obsolete: 8.2.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "10. Objects"
    10. title initialized to: "Garbage collection of object oriented Tcl commands"
    11. type initialized to: "RFE"
  2. Ticket change [077d056544] (rid 89410) by dkf on 2000-11-08 18:33:27:

    1. foundin changed to: "obsolete: 8.4a3"
    2. icomment:
      Seems like a reasonable idea to me to add "unnamed" commands that get GCed when their last reference disappears.  It would also be useful in Itcl and many other places.  Support for this could be done instead by making Tcl_CreateObjCommand() produce this sort of command when a NULL or empty string is passed for the command name (currently an error, or at least darned well ought to be.)  This would have the advantage of avoiding the horrible ...Ex function naming convention (which was invented by someone deeply demented; that MS use it a lot doesn't surprise me in the slightest!)
      
      Does this interact with Feather or some of the other ideas being bandied about for 9.0?  I suspect so...
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. priority changed to: "7 High"
    6. username: "dkf"
  3. Ticket change [fca9e98c64] (rid 108277) by dkf on 2001-01-09 21:56:52:

    1. icomment:
      Further discussion indicates that for this to be truly useful, great care will need to be taken to ensure that object-representations of these commands don't get lost too easily (Tcl_Objs were designed with the intention that the non-string form be just a cache of what would always be creatable from the string form, and not vice versa.)  This requires doing something much smarter than at present with substitutions into strings (the main way of accidentally losing non-string forms.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [a430553aeb] (rid 110171) by dgp on 2001-04-04 04:50:30:

    1. subsystem changed to: "47. Bytecode Compiler"
  5. Ticket change [7b60f61c6d] (rid 90504) by dkf on 2003-02-22 23:58:31:

    1. assignee changed to: "dkf"
  6. Ticket change [b6f2bcf7ab] (rid 125504) by dkf on 2009-03-24 23:24:08:

    1. icomment:
      Note — mainly so *I* don't forget — long-term want the things returned by TclOO's [$cls new] method to be GCed (unless they get [rename]d). Also see what tdom and tcom do.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [ce7ac759b6] (rid 96064) by dkf on 2009-07-13 01:21:50:

    1. priority changed to: "8"
  8. Ticket change [f70e8a332e] (rid 130425) by ferrieux on 2009-07-15 03:53:47:

    1. icomment:
      Donal, what I seem to recall from Feather, Mutability, and experience with tcom et al., is that GCing opaque handles is strictly incompatible with EIAS. What am I missing ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  9. Ticket change [ad990c904c] (rid 101494) by dkf on 2009-07-15 14:42:56:

    1. icomment:
      You're not missing anything.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  10. Ticket change [9547addfc3] (rid 106132) by ferrieux on 2009-07-15 16:48:55:

    1. icomment:
      Then what's the plan: 
       (a) reject this request
      or
       (b) accept to break EIAS the Feather way, by allowing second-class string-based containers to fail miserably:
      
            set x [Foo new]
            $x bar
            set mypoorcontainer haha:$x
            set y [lindex [split $mypoorcontainer :] 1]
            $y bar --> BOOM
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  11. Ticket change [22a474e77e] (rid 130785) by ferrieux on 2009-07-15 16:49:39:

    1. icomment:
      I forgot the obvious [unset x] right in the middle ;-)
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  12. Ticket change [8439b561e1] (rid 117511) by dkf on 2009-07-15 16:57:33:

    1. icomment:
      I'm thinking of doing the second. Yes, it's a theoretical problem. No, it's not a problem much in practice. (No, I'm not doing this for 8.6 in any case.)
      
      BTW, your example will break in other ways too; object names as returned by the factory methods are fully qualified. :-) But that's just an unfortunate choice of separator char; a comma would have demonstrated what you were looking to show.
      
      There are third and fourth options too: use explicit refcounting, tie to a scope (or rather to a variable lifetime). There are some interesting ideas here in the wider community (e.g., TclNAP) which is why doing something about this remains a big project; real research is needed...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  13. Ticket change [cb239ff716] (rid 95474) by ferrieux on 2009-07-15 19:34:37:

    1. icomment:
      OK. But let's prepare to hear again from people we dismissed with a swing of the EIAS club during the NULL cacophony...
      
      About (c) explicit refcounting and (d) var-binding:
      
      To me, (c) is just as manual as hand-destroying, so counts as (a).
      And (d) is already what (b) does, but with only a subset of active references (ie not counting references from within other Tcl values), so it will break even more respectable containers like lists and dicts. Eeeek !
      
      As for TclNAP, a cursory examination doesn't cleraly separate it from Feather-like "fragile" values, with just the extra tool of a script-level access to refcount-bumping (which I find rather ugly: better keep true references, so that you can enumerate them). So yet another variant of (b).
      
      Bottom line: you're about to open the Pandora Box. It will work "in practice", but Tcl will lose its soul...
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"