On Sat, Oct 15, 2016 at 8:59 AM, Andrei Zh <faithlessfri...@gmail.com>

> 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 and preserves type stability, but looks quite unintuitive.
> Is there more standard container or another way (e.g. type assertions or
> something) to handle such cases?

Use `const GLOBAL_VAR = Ref{MyType}()` and `GLOBAL_VAR[]`. The plan is that
this will essentially be how a typed non-const global be implemented in the

Reply via email to