Global scope confusion again

If I were to guess the broader point: the mental model of scoping he has in mind (that I can take almost any code and put a function around it, like you could do in v0.6) is broken, and he thinks that the new scoping rules are sufficiently perplexing that it is a signal of what else is counter-intuitive and possibly “buggy” in the language. It is not just about “writing global” occasionally, but about the inability to copy/paste code, reorganize in functions, etc. without thinking through scoping rules. This didn’t happen before, and doesn’t happen currently with jupyter. As you know, there are a lot of other people who agree with him that this is bad enough to be called “a bug”, however intentional it may have been.

But, I also think that this is an overreaction to this particular problem. The solution is simple, and it is what everyone I know dealing with introductory users is telling people:

  1. Never, under any circumstances, use loops etc. in the REPL or in a script, unless wrapped in a function. Period.
  2. If you want to do interactive work, for now you should generally use Jupyter which fixed this “bug” (of course, not really a bug in that it was intentional) with something called SoftGlobalScope, leading to the behavior of before.

If you follow this rule, you will never hit this problem. If I was to guess, the reason we don’t run into this more often is because (1) those teaching beginners always tell people to stick in jupyter, and (2) anyone who is not a beginner is already organizing code in functions.

@StefanKarpinski are there any updates on the timing of the https://discourse.julialang.org/t/another-possible-solution-to-the-global-scope-debacle/ solution?

1 Like