title: Run a parsed function in parallel in Julia
body: <p>I want to run a function in parallel, where the function is provided via a string argument. It is parsed from string to an Expression first and then run in parallel.</p>
  
  <p>The problem is that the string argument is not known to all worker processes.</p>
  
  <p>How can I make this work:</p>
  
  <pre><code>module test
  
  function run(f)
  
   @everywhere f_exp = eval(parse(f))
  
   values = SharedArray(Float64,2)
   @sync @parallel for i = 1:2
    values[i] = f_exp(i)
   end
  
   return mean(values)
  end
  
  end
  
  # RUN AS FOLLOWS
  # @everywhere include("c:\\projects\\evaluator\\test.jl")
  # test.run("function func(x) return 2*x end")
  </code></pre>
  
  <p>I also tried <code>@everywhere f_exp = eval(parse("@everywhere $f"))</code>, though I did not expect it to work... and it didn't.</p>
  
  <p>How can I make the argument known to every process?</p>
  
  <p>Doing <code>@everywhere f</code> as the first line in the function run also did not do anything.</p>