3 ms·
> This has been present for many years (for how long I do not know). Look up the "trace add variable ..." command. I suppose I should have been more explicit.
by lilyball 6y ago
> This has been present for many years (for how long I do not know). Look up the "trace add variable ..." command.
I suppose I should have been more explicit. I want to know when the value the variable holds goes away, so I can clean up the resources that value represents (for example, if the value names a unique namespace that groups related values, I want to delete the namespace once the name no longer exists).
I double-checked Tcl 8.6’s OO stuff and it says you need to explicitly destroy objects, they won’t be destroyed simply because they went out of scope, so even the core language isn’t doing this.
> This is possible (if a bit clunky) with Tcl of at least V8.5 vintage by using the "apply" command.
apply does not create a nested scope. It runs the code in the global namespace (or some other namespace you specify), so it has no access to the current scope unless you use upvar within the lambda. What I want is nested variable scopes that don’t require upvar to access the outer scopes.