Serializing a Module

What you could do instead is serialize a string or an expression of the string (see Metaprogramming), and then deserialize and evaluate that expression:

julia> ex = Meta.parse("module A; x = 1; end")
:(module A
  #= none:1 =#
  #= none:1 =#
  x = 1
  end)

julia> serialize("expression", ex)

and then in another process:

julia> eval(deserialize("expression"))
Main.A

julia> A.x
1

Whether this is a good idea or not, I will leave up to the reader.

1 Like