Now I'm having a hard time understanding how variables get passes to and from a 
local worker. In the following, I ask a local worker to to compute sin(x) and 
return the result. Notice that x is defined on the main worker, but @spawnat 
knows to send it's value to the local worker.

addprocs(1)
x=10
fetch(@spawnat 2 sin(x))

Why can't the same thing be done with a function?

foo(x) = sin(x)
fetch(@spawnat 2 foo(x)) #<--- gives an error

Of course, I could get this to work using @everywhere foo(x) = sin(x), but for 
my situation foo depends on a bunch of other functions, which are defined 
before I add the other workers and I don't want to redefine all these function 
with @everywhere once the workers are added. 

Any help would be appreciated:)

Reply via email to