>
> Something weird/unexpected does seem to be going on here:
>

There are some other edge cases like this where otherwise-top-level
expressions fail (essentially: the lowered code contains a `goto`, which
the interpreter doesn't support. so the thunk is sent to the JIT instead,
which can't yet handle `using`)

see e.g.
https://github.com/JuliaLang/julia/issues/2586
https://github.com/JuliaLang/julia/issues/4893

On Wed, Dec 9, 2015 at 10:50 AM, Josh Langsfeld <jdla...@gmail.com> wrote:

> But an if statement does not introduce new scope, correct?
>
> Something weird/unexpected does seem to be going on here:
>
> julia> VERSION
> v"0.5.0-dev+1491"
>
> julia> if true
>          using Compat
>          println("Using")
>          foreach(println, 1:3)
>        end
> Using
> 1
> 2
> 3
>
>
> julia> if true
>          using Compat
>          println("Using")
>          for i=1:3
>            println(i)
>          end
>        end
> ERROR: error compiling anonymous: unsupported or misplaced expression
> "using" in function anonymous
>  in eval at ./boot.jl:263
>
>
>
> On Wednesday, December 9, 2015 at 10:22:51 AM UTC-5, Steven G. Johnson
> wrote:
>>
>> A using statement affects the global scope, so it doesn't make a lot of
>> sense to evaluate it in local scope. That's why it's not allowed. The eval
>> function evaluates in global scope, so it can execute a using statement.
>>
>> In general, though, if you are eval'ing a using statement, you should
>> probably reorganize your code to do the using directly in global scope. For
>> example, put your code into a module if you want to keep the using
>> statement isolated from other code.
>>
>

Reply via email to