[julia-users] Re: Executing anonymous function on worker fails when wrapped in a module

2016-01-20 Thread Lutfullah Tomak
I get it now. Lowered code shows
return Banana.CPU_CORES
Even writing Base.CPU_CORES translated to
Banana.Base.CPU_CORES
I wonder if there is a direct way to eliminate Banana. prefix in lowered code.

[julia-users] Re: Executing anonymous function on worker fails when wrapped in a module

2016-01-20 Thread Lutfullah Tomak
Defining module as
@everywhere module Banana
.
end

and importing as

@everywhere using Banana

works for me. I don't know why it requires defining Banana module on remote 
worker though.

[julia-users] Re: Executing anonymous function on worker fails when wrapped in a module

2016-01-20 Thread 'Greg Plowman' via julia-users
OK, it seems a workaround may be to use something like eval(Base.Main, 
:(()->CPU_CORES)) in place of the standard anonymous function.

Below, Lemon.getCores(pid) doesn't work, Apple.getCores(pid) does work.

Is there a better way? This workaround seems awkward and overly complicated.

module Lemon
export getCores
getCores(pid) = remotecall_fetch(pid, ()->CPU_CORES)
end

module Apple
export getCores
getCores(pid) = remotecall_fetch(pid, eval(Base.Main, :(()->CPU_CORES)))
end


Still not sure whether using anonymous function,()->CPU_CORES, is a good 
way to return a global variable from a worker?

I also noted that eval'ing in Main, Base and Base.Main all seemed to work.
I'm not really sure about the differences between these modules. Can 
someone explain?

-- Greg