Get the latest tech news
Closures in Tcl
While closely following the discussions spawned from the recent Tcl/Tk 9.0 release, I've noticed a point that keeps coming up: the absence of closures. Usually the cue for every Tcl hacker in the world (a very large mob, let me tell you) to start showcasing various contraptions to emulate them.
If you have some mental energy to spare, I strongly recommend this fantastic article about the nitty-gritty of closures (actually, binding scope and lifetime) in ANSI Common Lisp to better understand the subtleties at play. But for closures, the task does seem a little harder… because while values are reference counted, variable bindings disappear once their stack frame is destroyed. In the craziest parts of my mind, I did imagine an environment writeback after each apply method call together with a way to disable that once leaving the stack frame where the closure was created (via an uplevel'd defer) but I'll let the idea sit for a while.
Or read this on Hacker News