What effect does that have on performance? (Of course, I want to have my 
cake and eat it too!)

On Tuesday, May 24, 2016 at 4:03:50 AM UTC-4, Ford Ox wrote:
>
> 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... 
>   
>
>

Reply via email to