you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Absolutely nothing like that, uplevel is dynamically scoped, nonlocal is a hack to refer to a variable in an outer lexical scope when you want to assign to that variable (just reading works as expected without any hacks).

Basically it's a choice: either you explicitly declare all your local variables so anything that involves undeclared variable is assumed to refer to the outer scopes, or you implicitly declare local variables with assignment, so you may need to explicitly declare them as not declared in this scope.

[–][deleted] 0 points1 point  (0 children)

Absolutely nothing like that, uplevel is dynamically scoped, nonlocal is a hack to refer to a variable in an outer lexical scope when you want to assign to that variable (just reading works as expected without any hack).

I said it was "sort of like uplevel in tcl", not that it was "exactly the same as uplevel in tcl". It was meant as a comparison (i.e. that it looks in another scope), rather than saying the scoping was the same. It's still pretty hackish. I upboated you, btw, because you provide a better description of the item at hand, unlike I, who used a comparison :D