I have developed 3 patches that enhance the usabiltiy [incr-tcl]. I'm making these patches available for anyones use. I've also sent these patches to Michael McLennon for his possible consideration. Now for the legal disclaimer. Use these patches at your own risk. These patches work for me when applied against the stock versions of itcl V1.5 and tcl V7.3. All of the tests are successful after these patches are applied. I've also ran purify against the executibles with these patches applied and also have build the tcl library with its memory debugging facilities enabled. There have been no problems found. In addition, I am using these patched versions in conjunction with other extensions in a single tclsh/wish. I have a swiss army wish that includes tcl/tk/tcl-dp/blt/itcl/tcl-debug/tclX/H.P. OpenView/snmp/ informix and all is well. I still cannot guarantee that they will work in all cases. --- destructor.patch: This patch ensures that an object cannot be removed from the interpreter without its destructor, if defined, being called. This patch adds a separate "alive" flag that is set when an object is created, cleared when an object's is destroyed through "delete", and finally tested when the object's resources are reclaimed. It is at this point that if the object is still "alive", its "delete" method is called to invoke the destructor. An object can be removed from the interpreter by a couple of methods that may not have its destructor called; by renaming it to nothing (rename $obj {}) or when the object is masquarading as a Tk widget (Tk removes the widget command from the interpreter itself). --- info.patch: This patch alters the "info" command to correctly output information about procedures, methods, and variables that have default values specified as {}. For example, without this patch, a procedure defined as: proc foo {a {b {}}} {} will be reported as: proc foo {a b} {} without the patch with the [incr tcl] info command. With the patch, it is reported as defined. --- vflag.patch and vscope.patch: These patches deal with the memory usage of [incr tcl]. These patches change the storage mechanism used for variable scoping. Using these patches I got the memory usage for an object instance down to about 320 byte for an object with one variable. I developed this patch when I noticed that one of my objects was using over 2k per instance. This is not a big deal for classes that do not have many instances created, but in my case, this class has 500 to 1000 instances regularly created. Multi-megabytes of memory was consumed. NOTE: the vflag patch must be made against V7.3 of Tcl. This patch is very short and mearly ensures that a special bit flag set on [incr tcl] variables is not cleared by Tcl. The second patch, vscope, must be applied against V1.5 of itcl. This patch is where the memory savings is made. Note that the patch does modify one of the expected test results for the uplevel test. This test involves the local variables reported by "info". With the patch installed, the "this" variable is reported as a local variable. In reality, this is true. A simple one line change to Tcl can stop this from being reported, but I did not think this was a big deal. As for memory usage, the memory usage looks like this: 72 bytes for the object structure 21 + nn bytes for a hash entry to keep track of the object 20 bytes for an entry in a list of objects to destroy 21 + nn bytes for the object command in the interpreter 16 bytes for the command structure in the interpreter 32 bytes for the "this" variable structure 10 bytes for the "this" variable value 20 bytes for the "this" variable hash entry 12 * ii bytes for the class scope structure 12 bytes for the "this" scope link entry where "nn" is the name of the object and "ii" is the number of classes in the inheritance heirarchy. For each variable that the object maintains, add the following: 32 bytes for the variable structure 10 + n bytes for the variable value 20 bytes for the variable hash entry 12 bytes for the variable scope link. where "n" is the length of the variable value that is > 10 bytes. I think there is also a 20 byte allocation to maintain the "preserve" data reference count. What my patch does is to limit the memory requirements for the variable scoping. It does this by maintaining one linked list (12 bytes per link) of all of the variables for the object, and another linked list of scopes (12 bytes per scope) of which there is one scope for each level in the inheritance hierarcy. My patch also eliminates the penalty for long variable names by using a one word hash for each variable. Brett Bergquist, Sr Principal Engineer | The MIB browser helps because it gives General DataComm, Inc., | you one place to be confused instead Middlebury, CT 06762 | of many." - Bob Stewart Email: brett.bergquist@corp.gdc.com Voice: (203) 758-1811 ext. 7635