Julia's loop scope behavior differs from Fortran?

Thanks lungben, the local DataVar statement seems to have gotten this kind of loop to work as I expected it to work in the first place.

While the discussion that my question triggered is all very interesting, and people seem to be repeating positions from previous debates, as a relative newbie to Julia, I’d like to put my two cents in on this.

First, while the documentation has some good info, it is incredibly sparse. I spend 2 or 3 times more time clicking back and forth between documentation pages and googling key phrases, trying to find specific useful info, than I spend actually reading documentation. There is an extreme shortage of actual programming examples, demonstrating the proper syntax of how to use the commands, and often I can’t even find a listing or explanation of the options available for the commands. There are also very few books on Julia, since it is a relatively new language, so it is very hard to pick up from scratch. Without this discussion board, I would have completely given up on the Julia programming language within a week.

Second, the entire “scope” setup of variables in Julia is a horror, plain and simple. I don’t care how many advantages it creates down the road, just writing a simple program with a detailed control flow leads constantly to errors and spurious results. Rather than debating how much detail is optimal to fill in on the “scope of variables” documentation, maybe the problem is that the entire approach is baffling from a common sense point of view. (Even if statement blocks sometimes create new scopes!?) Julia provides so many advantages in mathematical power, why completely reinvent the wheel on basic programming strategy? I just lost a week of productivity trying to figure out where my variables were going, it is incredibly frustrating.