# Using gensym properly

**URL:** <https://discourse.julialang.org/t/using-gensym-properly/3257>\
**Category:** General Usage\
**Tags:** macros, reactiveprogramming\
**Created:** [April 18, 2017, 12:58am UTC](https://discourse.julialang.org/t/using-gensym-properly/3257 "2017-04-18T00:58:06Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [April 18, 2017, 2:04am UTC](https://discourse.julialang.org/t/using-gensym-properly/3257/4 "2017-04-18T02:04:21Z")

</div>

> [@pyrex41](#):
>
> Will option 2 above work with every update to signal f pushing properly  
> through the macro, and arr always holding the last 5 values?

What do you mean by that?

> [@pyrex41](#):
>
> I had thought  
> that option 2 would mean that every time a new signal is pushed to f, a new  
> empty array “arr” would be created.

That’s what all versions above means. Your version included.

If you want a compile time generated (non-threadsafe and non-reentrant) array that are shared through multiple runtime execution of the same macro expansion, you can splice in the array directly (i.e. do `arr = []` in the macro and splice in this value and not the name). If you want some function local sharing then no it’s impossible and you shouldn’t do it. Any state that’s not local for a single macro should be explicitly managed.

---

_[View the full topic](https://discourse.julialang.org/t/using-gensym-properly/3257)._
