Confused about global vs local scoping in for loops in 1.0

Not wanting to add more noise to this topic, but just how I think about this.

A function is like a black box so variables go in (through the function arguments) and variables go out through return statements, so that’s makes sense that functions that their own scope.

But for, try, while blocks don’t really have an “input port” and neither do they have an “output port”. It would be different if there were something like a return statement to get stuff processed in those objects out but I don’t think there is, is there (other than setting those variables as global). It’s kind of like creating a black box with only a clear mechanism to get things in but not out.

What about If/else blocks. Why don’t those have local scoping rules similar to for/while/try?

2 Likes