# For loop globals in 0.7

**URL:** <https://discourse.julialang.org/t/for-loop-globals-in-0-7/13083>\
**Category:** General Usage\
**Created:** [August 9, 2018, 12:16pm UTC](https://discourse.julialang.org/t/for-loop-globals-in-0-7/13083 "2018-08-09T12:16:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [August 9, 2018, 12:16pm UTC](https://discourse.julialang.org/t/for-loop-globals-in-0-7/13083/1 "2018-08-09T12:16:27Z")

</div>

Can someone help me understand why the following loop has a deprecation warning in 0.7?

```julia
julia> t = 0.0;

julia> for j=1:10
           t += 0.1;
       end
┌ Warning: Deprecated syntax `implicit assignment to global variable `t``.
│ Use `global t` instead.
└ @ none:0

```

Other than just putting a `global` in to eliminate the warning, is there a “correct” way to accomplish this? I’d been going out of my way to avoid using globals, thus far.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [August 9, 2018, 12:23pm UTC](https://discourse.julialang.org/t/for-loop-globals-in-0-7/13083/2 "2018-08-09T12:23:04Z")

</div>

Putting the `global` on it is the correct way to do this now. For loops always introduce local scope and assignment in local scope always creates a new local variable now. The old, widely misunderstood behavior was that this would update a global of one was already defined and would otherwise introduce a new local. This lead to confusing/ed explanations about “soft” and “hard” scope. That distinction no longer exists: there is only one kind of scope. The flip side of this is that you need a `global` here. We might special case the REPL in the future to make this work the way you expect it to but what it would actually be doing would be transforming your code to this:

```julia
t = let t = t
     for j = 1:10
          t += 0.1
     end
end

```
