# Basic of \`@everywhere\` and \`@distributed\` macro

**URL:** <https://discourse.julialang.org/t/basic-of-everywhere-and-distributed-macro/100498>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [June 17, 2023, 8:37pm UTC](https://discourse.julialang.org/t/basic-of-everywhere-and-distributed-macro/100498 "2023-06-17T20:37:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [June 18, 2023, 10:38pm UTC](https://discourse.julialang.org/t/basic-of-everywhere-and-distributed-macro/100498/4 "2023-06-18T22:38:38Z")

</div>

unfortunately macro based multi threading and multi processing both seems confusing at best, brittle / fragile at times.

> [@Confusing julia behavior. @everywhere macro changes the scope of local variables to global](http://discourse.julialang.org/t/confusing-julia-behavior-everywhere-macro-changes-the-scope-of-local-variables-to-global/77436/6):
>
> I find this a bit confusing as well. One thing that often adds clarity is to replace macros with the code executed. In this case: julia\> using MacroTools julia\> prettify(@macroexpand(@fetchfrom 2 x)) :(Distributed.remotecall\_fetch((()-\>x), 2)) so @fetchfrom 2 x actually means remotecall\_fetch(() -\> x, 2) i.e. it creates a closure around x, and then executes the result on pid 2. I can see how that ends up returning 1 given the closure is created on pid 1 and therefore likely closes over the …

---

_[View the full topic](https://discourse.julialang.org/t/basic-of-everywhere-and-distributed-macro/100498)._
