Hi,

I can't explain the behaviour of this:

macro wtf1()
    return esc(
        :(begin
            @show a
            @everywhere const b = a
            @show b
        end))
end

macro wtf2()
    return esc(
        :(begin
            @show c
            const d = c
            @show d
        end))
end

@everywhere const a = 0
@wtf1
@everywhere const a = 1
@wtf1
@everywhere const a = 2
@wtf1

println()

const c = 0
@wtf2
const c = 1
@wtf2
const c = 2
@wtf2

results in:

a = 0
b = 0
WARNING: redefining constant a
a = 1
WARNING: redefining constant b
b = 0
WARNING: redefining constant a
a = 2
WARNING: redefining constant b
b = 1

c = 0
d = 0
WARNING: redefining constant c
c = 1
WARNING: redefining constant d
d = 1
WARNING: redefining constant c
c = 2
WARNING: redefining constant d
d = 2

Why do the outputs of the two macros differ? Shouldn't it be the same?

And why does julia warn me about the redefinition of b when it doesn't 
really redefine it. (line 5 and 6 of the output)

Reply via email to