A little bit more on the topic of encapsulation, if somebody desperately wants it.
module... export... type Foo x end type Holder{T} x::T end # don't export this one setfield(f::Foo, key, value::Holder) = f.key = value.x setfield(f::Foo, key, value) = raise error... # Other functions... end Only functions from module will be able to wrap values into Holder, so all methods defined elsewhere will raise error when trying to modify Foo variables...