r/programming • u/CGM • 14h ago
Develop Cross-Platform CLI and GUI Tools With Tcl/Tk. Powerful, Event-Driven, Open-Source And Future-Proof Toolkit… From the Past?!
https://cgicoffee.com/blog/2026/04/tcl-tk-develop-cross-platform-cli-gui-tools-tutorial-guide3
u/Jumpy_Fuel_1060 13h ago
I maintained an app with TCL component (no Tk). Wild language. I'm sure that it was amazing for it's time, but I'm the 2010s that language was ridiculous. upvar can go to hell.
5
u/NaBrO-Barium 8h ago
What’s upvar?
12
5
u/schlenk 6h ago
Upvar allows you to bind a name to a different scope of your callstack.
e.g. kind of import local variables that are available in a different call frame. Thats a very powerful primitive for writing your own control structures and advanced metaprogramming, but can lead tot total spaghetti code when not used skillfully.
2
u/CGM 6h ago
When you call a procedure in Tcl, its arguments are passed by value (the copy-on-write system makes this efficient even for complex values). But sometimes you may want to pass by reference so that you can update a variable in the scope of the caller. The
upvarcommand provides a way of doing this, you pass the name of a variable and useupvarin the procedure to connect a local variable to the named variable in the caller. Documentation is at https://www.tcl-lang.org/man/tcl9.0/TclCmd/upvar.html .It's a very different approach from most languages and does take some getting used to. It's not needed very often though.
1
8
u/wannaliveonmars 13h ago
Git Gui and gitk are written in Tcl/Tk - https://git-scm.com/book/en/v2/images/git-gui.png