3 ms·
Re [1]: the libraries that delete an object when it goes out of scope use Tcl's built-in "trace" command, which lets you execute code when a command terminates
by blacksqr 5y ago
Re [1]: the libraries that delete an object when it goes out of scope use Tcl's built-in "trace" command, which lets you execute code when a command terminates or when a variable is deleted, among other events. So no, it's all done in pure Tcl.
- lilyball 5y agoOh it looks like I misremembered. I thought the API I had used was something like `set doc [foo parse $input]` and the document would go away when the variable does. I found it, it's the tDOM library, and it was actually `dom parse $xml doc` that does the automatic freeing, whereas `set doc [dom parse $xml]` requires manual deletion. So it probably is using trace.
- rkeene2 5y agoThis is how the "defer" [0] command (from tcllib) in Tcl works. [0] https://core.tcl-lang.org/tcllib/doc/tcllib-1-19/embedded/www/tcllib/files/modules/defer/defer.html https://core.tcl-lang.org/tcllib/doc/tcllib-1-19/embedded/ww...