5 ms·
I'm familiar with parts of TCL, but I still can't arrive at a good answer for those questions. It has a unique (wild and strange) feature called upvar that I h
by 0xdeadbeefbabe 11y ago
I'm familiar with parts of TCL, but I still can't arrive at a good answer for those questions.
It has a unique (wild and strange) feature called upvar that I haven't seen in python or lua. You "use" it to reference a previous frame in your call stack.
- davidw 11y agoYou can use upvar and uplevel to write control structures (if, while, that kind of thing) in Tcl itself. For instance, Tcl itself does not have a do ... while loop, but you can write one that will look like it's part of the language. Also: it's Tcl, by the way, not TCL.
- beagle3 11y agoLua has something called an "upvalue" but it's a completely different thing. Lobster[0] also lets you write do/while loops and new conditionals, but does that in a different way that does not require upvar/uplevel, and is IMHO cleaner. (It is less capable in general, but captures 99% of the use cases that I've seen for upvar/uplevel in Tcl) It is indeed Tcl, but it IS an acronym for "Tool Command Language", or at least started out that way. [0] http://strlen.com/lobster http://strlen.com/lobster
- sigzero 11y agoThe acronym is true but the community uses Tcl now and has for quite a while.
- amyjess 11y agoStuff like this intrigues me, from a linguistic perspective. I'm really curious what lead to the community settling on this. You'll occasionally see all-lowercase in some projects thanks to the fact that *nix commands are usually all-lowercase, but title-casing an acronym is weird. If I had to hazard a guess, I'd say it's because "Tcl" is typically pronounced as a word ("tickle"), so it got de-acronymized like "radar" or "scuba". Then again, nobody writes SCSI as Scsi. I'd love to study this some more...
- davidw 11y agoMy guess: it's kind of a fashion thing. FORTRAN and COBOL and FORTH and whatnot are a bit old fashioned looking. https://en.wikipedia.org/wiki/Fortran#Naming https://en.wikipedia.org/wiki/Fortran#Naming
- _ph_ 11y agoYou can actually reference any frame in the stack all the way to the top. And it has a companion "uplevel" which allows you to evaluate code on any of those stack frames. But usually both are used only with the previous stack frame. This allows TCL functions to mostly behave like macros.
- smrtinsert 11y agomanipualting stack is exhilarating once you understand it. I learned clojure way after my tcl so now in retrospect I think of it as a macro system - keep it hygenic!