Using ReactiveBasics.jl, I have been using signals to deal with event-driven time series event modeling. I find that using a reactive style approach is intuitive and improve the clarity of my code. My question, though, is how to go about using gensym properly.
f = Signal(n)
now, i want to build a function and/or macro that will let me apply a specific transformation to an arbitrary Signal. In order to get the median value of the last 5 values of the Signal, I need to create an array that exists separately from the signal:
macro medWin(sig, arr, win = 5) quote $arr =  flatmap($sig) do iv unshift!($arr, iv) length($arr) > win ? pop!($arr) : false median($arr) |> Signal end end end med_signal = @medWin(f, arbitrary_array_name, 5)
This works. However, I realized that I do not really care what “arbitrary_array_name” is, just that it is unique. I never reference it outside the function/macro “medWin”. This seems a clear case for gensym(). However, I cannot seem to get my quote notation, $ interpolations, and eval calls set up to make this work properly. Can someone help me see how to implement this more clearly? Alternatively, perhaps there is a better way to go about this task.