Hi all, I'm trying to figure out basic communication patterns for Julia's parallel computing framework. I'd like to write up a little tutorial when I'm done, since the documentation on this (in my opinion) is a bit sparse.
The basic question is why this doesn't define `x` on worker #2: *@spawnat 2 x=1* Meanwhile this seems to work: *@spawnat 2 eval(:(x=1))* And this seems to work if you want to define `x` on all procs: *@everywhere x=1* To be clear, by "working" I mean that running *fetch(@spawnat 2 x)* will return 2 only in the second two cases. The first case throws an error (`x` not defined on worker 2) . I tried using macroexpand to see the difference. I don't have a good sense of what things like `*:copyast*` and `*:localize*` mean. If someone could help me parse this, I'd greatly appreciate it. *julia> **macroexpand(:(@spawnat 2 x=1))* *:(Base.spawnat(2,$(Expr(:localize, :(()->begin # expr.jl, line 113:* * ()->begin # multi.jl, line 1358:* * x = 1* * end* * end)))))* *julia> **macroexpand(:(@spawnat 2 eval(:(x=1))))* *:(Base.spawnat(2,$(Expr(:localize, :(()->begin # expr.jl, line 113:* * ()->begin # multi.jl, line 1358:* * eval($(Expr(:copyast, :($(QuoteNode(:(x = 1)))))))* * end* * end), :eval))))* Apologies if there is a good explanation of this elsewhere on the web. You can just point me there if so. -- Alex