Evaluating expressions in file

Well, I suggested two (or three, depending how you want to count) versions that do what you want. After the more detailed explanation I wouldn’t advise the second version but the first version (both that in the global scope as well as that with the struct) should work fine. What do you think about those?

Edit: What I mean with “the struct version”:

mutable struct A
    x::Int
    y::Int
    z::Int
    A() = new(0, 0, 0)
end
a = A()
record = "x = 1"
n = split(record)[1]
v = parse(Int, split(record)[end])
setproperty!(a, Symbol(n), v)
f(a)
1 Like