| Mark Janssen 2008-01-30, 7:46 pm |
| On Jan 30, 8:36 pm, "tom.rmadilo" <tom.rmad...@gmail.com> wrote:
> On Jan 30, 11:16 am, Mark Janssen <mpc.jans...@gmail.com> wrote:
>
>
>
> When I look at the code above, I don't see any [uplevel]. Logical
> means the logical meaning of the code, not how something happens
> behind the scenes. If the loop was in C, you wouldn't talk about
> [uplevel]. It is not logically part of the idea of a loop. Levels are
> actual, they are physical. They either exist or they don't. But
> regardless of how things are done, the loop body is effectively
> executed in the context of the caller, not in some other space. If you
> were required to think of these details when using a loop, it wouldn't
> be fun.
Logically everything in Tcl is a command (also foreach). So for the
body to be executed in the current scope it has to be upleveled. The
fact that in C there is no context doesn't mean that in Tcl there
isn't. In Tcl everything is a command. Control structures as in C
simply don't exist (logically) it's just a command that does some
stack level juggling. From basic principles one can deduce that there
is an uplevel somewhere without looking behind the scenes.
|