# Writing better / faster / more julia-ish code

**URL:** <https://discourse.julialang.org/t/writing-better-faster-more-julia-ish-code/3269>\
**Category:** General Usage\
**Tags:** macros, reactiveprogramming\
**Created:** [April 18, 2017, 4:57pm UTC](https://discourse.julialang.org/t/writing-better-faster-more-julia-ish-code/3269 "2017-04-18T16:57:43Z")\
**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, 6:46pm UTC](https://discourse.julialang.org/t/writing-better-faster-more-julia-ish-code/3269/4 "2017-04-18T18:46:38Z")

</div>

> [@pyrex41](#):
>
> I did not expect the macro approach to work like this, either; however, I tried this based on this thread. To demonstrate:
> 
> ff = Signal(0.0)  
> gg = @medWin(ff,3)

I’m not sure what you are expecting but [the difference between the two is that](https://discourse.julialang.org/t/using-gensym-properly/3257/4) by splicing in the value, you have

> a compile time generated (non-threadsafe and non-reentrant) array that are shared through multiple runtime execution of the same macro expansion

Which doesn’t seems to be what you want unless you want multiple invocation at **runtime** to affect each other or you will never use this macro in a function or a local scope.

Your domonstration doesn’t show the difference between generating the array at compile time and runtime. You should only do this if you really know what it is doing. Trying things and observing something that seems to work without understanding/checking the document is one of the major reason why people write code/packages that breaks easily due to changes in base. (It’s unlikely that this particular behavior will break but it’s a bad habit to do so.)

---

_[View the full topic](https://discourse.julialang.org/t/writing-better-faster-more-julia-ish-code/3269)._
