Why won't julia ERROR if a variable is not defined when scheduling?

There is also the additional point that you’re (sometimes) allowed to reference variables before (in terms of location in code) they are declared, which is not related to multi-threading. E.g.

julia> function main()
           inc_c() = c += 1  # What is c at this point?
           c = 1
           inc_c()
           println(c)
       end;

julia> main()
2

(See also Is it okay that, in Julia, code that never executes can change the result of programs? - #21 by frankwswang)

1 Like