Houtan Bastani houtan.bastani@ens.fr writes:
So, this means it is OK to have symbols that take on different values in different scopes. Ie in:
co <- "abc" countries <- {US JA FR}
for (co in countries) { ... }
would be valid code and co would take the values of countries within the scope of the for loop and "abc" both before and after the loop.
In this context it is debatable. In some languages like C, co would be restored to "abc" after the loop; but not in R for example.
The question is whether a "for" loop pushes a new environment on the environment stack containing only one variable (the indexing variable).
I think that it is simpler if we consider that a for loop does not create a new environment, and therefore that in your example co is equal to "FR" after the loop.
To make our language simple, I think only function calls should push new environments on the environment stack (like R does).