remotecall_fetch(() -> println("Hello world"), 2)

or

helloworld = () -> println("...")

gets sent properly.

In general a named generic function gets serialized by means of its name
and not body, and that's why you get an undefined value error.

(also you can't just close a named function in a anonymous function, e.g. ()
-> myfun() won't work unless myfun is already available on the remote
process.)


On Tue, Mar 1, 2016 at 7:21 PM, Pranav Bhat <[email protected]> wrote:

> Consider the following code:
>
> addprocs(2)
> function helloworld()
>    println("Hello World")
> end
>
> remotecall_fetch(helloworld, 2)
>
> This throws an error because the function helloworld isn't defined on
> process 2. I've found a couple of workarounds:
> 1. Use @everywhere while declaring the function
> 2. Place the function in a file or module and include it everywhere.
>
> Are there any alternatives to this? I would like to pass around functions
> like they were regular data items.
>

Reply via email to