Concise way to initialize field in terms of another field

at syntax level this will never work, because a+9 needs to be computed first.

The best you can do is make a macro yourself that would transform this to:

let a=6, b=a+9
    x = Example(; a, b)
end

since it looks like let would resolve it in order:

julia> let a = 9, b=a+9
           a,b
       end
(9, 18)
1 Like