3 ms·
> And yet I still can't get my head around upvars. I haven't used Tcl for maybe 15 years, but if I recall correctly upvar was basically an alternative to lack
by takeda 7y ago
> And yet I still can't get my head around upvars.
I haven't used Tcl for maybe 15 years, but if I recall correctly upvar was basically an alternative to lack of pointers.
What it was doing was giving you access to a variable from specific stack frame.
You could say I want to access variable from the function that called me.
upvar and it's interesting syntax allowed to create new "statements" for example in earlier versions of tcl (because looks like it was added later) you could implement try-catch "statement" and it would behave as if it was part of the language.
- RHSeeger 7y ago> upvar and it's interesting syntax allowed to create new "statements" for example in earlier versions of tcl (because looks like it was added later) you could implement try-catch "statement" and it would behave as if it was part of the language. This is one of the things I miss most when using other languages. Outside of actual lisps (of which I consider Tcl to be one), there's very few languages that allow you to build your own control structures. Ruby comes close, but doesn't really have the same flexibility.
- takeda 7y agoHere is the recipe I was referring to: http://code.activestate.com/recipes/68396-try-catch-finally/ http://code.activestate.com/recipes/68396-try-catch-finally/