Skip to content

Commit

Permalink
document use of @eval with @Everywhere for broadcast of local variables.
Browse files Browse the repository at this point in the history
Proposed by Ben Arthur (@bjarthur) [ci skip]
  • Loading branch information
amitmurthy committed Apr 20, 2016
1 parent c7643cd commit 726174d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,19 @@ download
@everywhere
Execute an expression on all processes. Errors on any of the processes are collected into a
`CompositeException` and thrown.
`CompositeException` and thrown. For example :
@everywhere bar=1
will define `bar` under module `Main` on all processes.
Unlike `@spawn` and `@spawnat`, `@everywhere` does not capture any local variables. Prefixing
`@everywhere` with `@eval` allows us to broadcast local variables using interpolation :
foo = 1
@eval @everywhere bar=\$foo
"""
:@everywhere

Expand Down
15 changes: 14 additions & 1 deletion doc/stdlib/parallel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,20 @@ General Parallel Computing Support

.. Docstring generated from Julia source
Execute an expression on all processes. Errors on any of the processes are collected into a ``CompositeException`` and thrown.
Execute an expression on all processes. Errors on any of the processes are collected into a ``CompositeException`` and thrown. For example :

.. code-block:: julia
@everywhere bar=1
will define ``bar`` under module ``Main`` on all processes.

Unlike ``@spawn`` and ``@spawnat``\ , ``@everywhere`` does not capture any local variables. Prefixing ``@everywhere`` with ``@eval`` allows us to broadcast local variables using interpolation :

.. code-block:: julia
foo = 1
@eval @everywhere bar=$foo
.. function:: Base.remoteref_id(r::AbstractRemoteRef) -> (whence, id)

Expand Down

0 comments on commit 726174d

Please sign in to comment.