I'm revising the notes for my JuliaCon workshop, and wondering if there is 
a standard way/convention for the following hack to reduce the overhead of 
accessing a global variable.  The hack is to replace a global variable, if 
known to always be bound to objects of the same type, with a const variable 
that wraps a reference to the the object.  For example, instead of writing:
x = 0.0

function inc_global()
   global x
   x += 1
end

we would write:

type wrapper{T}
    x::T
end

const x = wrapper(0.0)

function inc_global()
    w.x += 1
end

Is there a standard library type that serves the purpose of `wrapper`, or a 
standard type that can be abused to do so?

Reply via email to