Includes and loops

This is not a bug.

My understanding is that include operates in the global scope using essentially the same mechanisms as eval. By design, Julia is not intended for this sort of locally scoped file inclusion stuff because it’s just generally a bad way to write code.

If you want to do something like this, you should change bug2.jl to contain a function:

N(k) = 2^k

and then write

include("bug2.jl")

for i=1:10
	k=3
    N(k)
end
9 Likes