4 ms·
I don't really have much of a need for garbage collection, but I did investigate strong/weak references (which I would probably prefer over garbage collection).
by flafoar 9y ago
I don't really have much of a need for garbage collection, but I did investigate strong/weak references (which I would probably prefer over garbage collection). See http://wiki.tcl.tk/41605 http://wiki.tcl.tk/41605. That's the best I could do with my limited knowledge of the Tcl internals. My suspicion at the time was that if the Tcl core team really wanted to implement strong/weak references, then they would probably be able to come up with a proper way of doing that. And if they could do that they could do garbage collection. But I don't really know ...
- int_19h 9y agoI think the problem with such systems is that they have to contend with the infinite varieties of ways references can be stashed away. When a local is itself a reference string, that's well and good. What if it's a string that has a reference embedded in it somewhere? But that effectively describes all Tcl data structures...
- flafoar 9y agoYes, the way I was looking at strong/weak references was that strong references could only be held as a value in local/global/class variables, including in lists and dictionaries. And converting a strong reference to a string would give you a weak reference. So you wouldn't be able to, say, convert a list that included a strong reference to a string, then convert the string back to list, and have exactly the same list that you started with because the strong reference in the original list would be a weak reference in the resulting list. Strings can represent list and dictionary data structures, and combinations of, but I'm not sure that strings represent all Tcl data structures in the same way. I'm thinking of Tcloo and Tcl arrays - I don't use those and know little about them.