Closures in Tcl
Published on: 2025-07-31 07:08:29
What's a song or album that you enjoy that you wish had more recognition?
How often do you discover music? And how do you discover music?
Do you listen to the radio? If so, how often?
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. So here's my turn.
What kind of closures §
But first, let me explain that what I think of when I read the word "closure". You see, most C++ers would say that this is a closure:
#include auto make_counter ( int x = 0) { return [x]() mutable { return ++x;}; } int main ( void ) { auto counter = make_counter(); printf( "counter: %d
" , counter()); printf( "counter: %d
" , counter()); }
But the environment isn't closed over here, it's simply copied and this copy is then allowed to be m
... Read full article.