Hey Stefan,
I figured it out. I had to do something along these lines:
x = 2.0
function change_variable(z)
eval(:($z = 3.0))
end
change_variable(:x)
On Friday, March 25, 2016 at 12:00:50 PM UTC-7, Stefan Karpinski wrote:
>
> You may want to check out Interact.jl:
> https://github.com/JuliaLang/Interact.jl
>
> On Fri, Mar 25, 2016 at 1:59 PM, Lewis Lehe <[email protected]
> <javascript:>> wrote:
>
>> Err that is
>>
>> slider[:on_changed](
>> #WHERE I WANT THE MACRO TO GO
>> variable = slider.val
>> )
>>
>>
>>
>> On Friday, March 25, 2016 at 10:57:34 AM UTC-7, Lewis Lehe wrote:
>>>
>>> Hi,
>>> I am learning about metaprogramming and macros. I have a very basic case
>>> but am unsure about what Julia is capable of. last time I asked a question
>>> here I got a very helpful answer shortly.
>>>
>>> I am making sliders for a matplotlib plot. I would that when a slider
>>> changes, it changes some the value of some variable. Here is an example.
>>>
>>> frequency = 2.0
>>> function makeSlider(axSlider, variable):
>>> slider = widget.Slider(axSlider; valinit=variable)
>>> slider.on_changed(
>>> #WHERE I WANT THE MACRO TO GO
>>> variable = slider.val
>>> )
>>> slider
>>> end
>>> freqSlider = makeSlider(axFrequency,frequency)
>>>
>>>
>>> Is this possible? I did not see any use cases like this in the
>>> documentation.
>>>
>>> I would normally do it by keeping all my constants as properties of some
>>> World type (or in some world Dictionary) and passing the key to the
>>> function, but I wanted to learn how to use this part of Julia.
>>>
>>> Thanks!
>>>
>>
>