On Tue, 2016-04-12 at 11:03, Didier Verna <did...@didierverna.net> wrote:
> What is the rationale behind module state being read-only from the outside?

Encapsulation?  Seems good to me.

> Is this only be default (i.e., is there a construct to still allow
> writing)?

Use a function

julia> module A
       a = 1
       moda(newa) = global a=newa
       end
A

julia> A.a
1

julia> A.moda(2)
2

julia> A.a
2

You can also eval into a module:


julia> eval(A, :(b=2))
2

julia> A.b
2

julia> eval(A, :(f()=22))
f (generic function with 1 method)

julia> A.f()
22

(but use this extremely sparingly!)

Reply via email to