Re: [julia-users] Type-stable global variables?

2016-10-15 Thread Andrei Zh
Thanks, this is exactly what I was looking for. On Saturday, October 15, 2016 at 4:08:48 PM UTC+3, Yichao Yu wrote: > > > > On Sat, Oct 15, 2016 at 8:59 AM, Andrei Zh > wrote: > >> What is the most straightforward way to make a variable in the global >> scope that can

Re: [julia-users] Type-stable global variables?

2016-10-15 Thread Yichao Yu
On Sat, Oct 15, 2016 at 8:59 AM, Andrei Zh wrote: > What is the most straightforward way to make a variable in the global > scope that can change it's value, but not its type? So far I use this: > > const GLOBAL_VAR = [MyType[]] # array with single element > >

[julia-users] Type-stable global variables?

2016-10-15 Thread Andrei Zh
What is the most straightforward way to make a variable in the global scope that can change it's value, but not its type? So far I use this: const GLOBAL_VAR = [MyType[]] # array with single element set_global_var(x::MyType) = GLOBAL_VAR[1] = x get_goval_var() = GLOBAL_VAR[1] This works fine