This does not solve your problem, but you will get closer if you declare f
as global so that you do not write to a local variable that will go out of
scope as soon as it gets declared.
open("f.jld", "r") do file
global f = deserialize(file)
end
f(1)
ERROR: function f not defined on process 1
in error at error.jl:21
in anonymous at serialize.jl:353
I am not sure how deserialization of functions is intended to work, so this
is all I could do.
kl. 07:32:29 UTC+1 tirsdag 28. januar 2014 skrev Cristóvão Duarte Sousa
følgende:
>
> Hi,
>
> I would like to do something like
>
> f(x) = x+1
> open("f.jld", "w") do file
> serialize(file, f)
> end
>
> then, close julia, open it again and do
>
> open("f.jld", "r") do file
> f = deserialize(file)
> end
> f(1)
>
> but that gives "ERROR: f not defined"
>
>
> Is serialization supposed to be able to do this?
> If yes, which is the right way to code it?
>
> Thanks
>