4 ms·
Tcl is one of my favorite scripting languages to work in. It’s wonderful in the simplicity of the core language and how you can write things that act like keywo
by lilyball 6y ago
Tcl is one of my favorite scripting languages to work in. It’s wonderful in the simplicity of the core language and how you can write things that act like keywords as just pure Tcl. I’d love to see Tcl gain some modern sensibilities like closures, the ability to run a destructor when a variable falls out of scope or is deleted, nested variable scopes within a proc, etc.
- pwg 6y ago> the ability to run a destructor when a variable falls out of scope or is deleted This has been present for many years (for how long I do not know). Look up the "trace add variable ..." command. > nested variable scopes within a proc, This is possible (if a bit clunky) with Tcl of at least V8.5 vintage by using the "apply" command. According to this page (https://stackoverflow.com/questions/1478510/when-was-tcl-v8-5-first-released-for-production https://stackoverflow.com/questions/1478510/when-was-tcl-v8-...) 8.5 was first released Dec. 20, 2007, so this one has been possible for 13 years.
- rkeene2 6y agoI wrote a "defer" command in Tcl using this !
- 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.